problems with own EditItem (cMenuEditIpNumItem)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there, 
I have derived my own class cMenuEditIpNumItem  from cMenuEditItem. 
It displays 4 segments, seperated by dots. 

My Problem is _SOMETIMES_ if kOk is pressed,  the item  remains in insert mode. 
If so, pressing  kLeft, kRight release this behaviour.  

Explanation: 
Edit mode are  indicated with brakets: 

  "My IP Address                    192.[168].10.3 


int pos               segment counter, range 0-4, greater than  0 means edit mode
int digit             digit of actual segment.  
unsinged char val[5]  container for IP values.  actuall 4 segments 1-4  are used. val[0]  is not used. 
                                      --- unsinged char will be used  as unsigned int 0 -255.
 
  char *value        the actuall string displayed in menu item. 




I have no Idea where the Problem coud be. Of course, the  "ProccesKey"-Funktion gets   the correct  key code. 

for the hole class see attachment. 


------------------------------- Schnipp -------------------------------------------------------



OSState cMenuEditIpNumItem::ProcessKey(eKeys Key)
{

  eOSState state = cMenuEditItem::ProcessKey(Key);

  Key = NORMALKEY(Key);

  switch (Key) 
  {
     case kBack: 
                if (pos != 0)
                  pos = 0;
                else 
                  return cMenuEditItem::ProcessKey(Key);
          break;


     case kLeft: {
            if (pos > 1)
               pos--;
            if (pos == 0)
               pos = 4;

            digit = 0;
            }
            break;
     case kRight: {
            if (pos < 4)
                pos++;

            digit = 0;
            }
            break;
     case kUp: 
            if (pos != 0) {
                 val[pos]++;
                 digit = 0;
            }
                else 
                return cMenuEditItem::ProcessKey(Key);
            break;
     case kDown: 
            if (pos != 0) {
                 val[pos]--;
                 digit = 0;
            }
            else 
                return cMenuEditItem::ProcessKey(Key);

            break;
     case k0 ... k9: {
                //dsyslog(DBG_PREFIX  "k0 ... k9 digit %d val[%d]  ", digit, pos);
                if (pos != 0)
                {
                  if (digit > 2) // ??? 
                  {
                    digit = 0;
                    if (pos < 4) pos++;
                  }

                  if (digit == 0)  val[pos] = 0;

                  char tmp[4];
                  snprintf(tmp,4, "%d",val[pos]); //XXX  ??? 
                  tmp[digit] = Key - k0 + '0';
                  digit++;
                  tmp[digit] = '\0';

                  #if 0
                  dsyslog(DBG_PREFIX  "digit %d val[%d]  ", digit, pos);
                  dsyslog(DBG_PREFIX  "val %d tmp %s", val[pos], tmp);
                  #endif
				  

                  val[pos] = Validate(tmp);

                  #if 0
                  int len = strlen(tmp);
                  dsyslog(DBG_PREFIX "key: k%d, val[pos]:%d, digit: %d pos %d, len:%d ", 
                                      Key - k0, val[pos], digit, pos, len);
                  dsyslog(DBG_PREFIX  ">>> tmp %s ",tmp);
                  #endif
                }
                Set();
           }
           break;

     case kOk:
			//if (pos < 1 ) 
			  //return cMenuEditItem::ProcessKey(kNone); 
	        pos = 0; 
			digit = 0;
			return cMenuEditItem::ProcessKey(kNone); 
		    //break;	

     default: 
			return cMenuEditItem::ProcessKey(kNone); 
  }

  Set();
  return  osContinue;

}




------------------------------- Schnapp -------------------------------------------------------

Thanx for Help 
  Markus 
-- 

mhahn@xxxxxxxxxxxxxxxxxxx
www.Reel-Multimedia.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cMenuEditIpNumItem.tarbz2
Type: application/x-bzip2
Size: 1841 bytes
Desc: not available
Url : http://www.linuxtv.org/pipermail/vdr/attachments/20060721/1ac27d99/cMenuEditIpNumItem.bin

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux