Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
Posts: 3
Registered: ‎08-10-2011
My Device: 9000 Bold
My Carrier: Developper
Accepted Solution

[ChoiceField] Catch all events

[ Edited ]

Hi,

 

I'm a new French Blackberry developper (and not very good in english so : excuse me in advance Smiley Wink )

 

I want to develop an application to manage bank accounts (JDE 5.0).

 

I have a screen to create a new account with a choice field to select the corresponding bank : bank 1, bank 2, create a new bank.

 

When the user select the last item (create a new bank), a new screen appears.

 

final ObjectChoiceField bankList = new ObjectChoiceField("Bank:",bankTab,0){
   public boolean navigationClick(int status, int time) {
      if (this.getSize()<=0) {
         UiApplication.getUiApplication().pushScreen(new frmEditBank(dbobj));
         return true;
      } else return false;
   }    		    
   public boolean keyChar(char key, int status, int time){
      if ( (((String)bankData.elementAt(this.getSelectedIndex())==""))||(this.getSize()<=0) )
         UiApplication.getUiApplication().pushScreen(new frmEditBank(dbobj));
      return false;
   }
};
bankList.setChangeListener(new FieldChangeListener() {
   public void fieldChanged(Field field, int context) {
      if (context==ObjectChoiceField.CONTEXT_CHANGE_OPTION) {
         if (((String)bankData.elementAt(((ObjectChoiceField)field).getSelectedIndex())==""))
            UiApplication.getUiApplication().pushScreen(new frmEditBank(dbobj));
      }
   }    		    		        	
});

 I want to manage : barspace, mouse clic (when no bank exists) and "New bank" option select.

 

Anyone have ideas to correct/improve this code ?

 

Thanks for your help Smiley Happy




 

Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: [ChoiceField] Catch all events

welcome to the support forums.

your code looks good, you chose the correct methods to overwrite.
if you want only the space key you can check for the key variable to be http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/system/Characters.html#SPACE
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Contributor
Posts: 3
Registered: ‎08-10-2011
My Device: 9000 Bold
My Carrier: Developper

Re: [ChoiceField] Catch all events

Thanks for your answer Smiley Happy

 

Yes i want to catch the space key, so I can use the SPACE constant.

 

But the problem is that the "keyChar" method doesn't work. When I press the space key, the event is correctly catched but the selection doesn't move to the next choice in the list...

Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: [ChoiceField] Catch all events

try returning super.keyChar instead of false.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
New Contributor
Posts: 3
Registered: ‎08-10-2011
My Device: 9000 Bold
My Carrier: Developper

Re: [ChoiceField] Catch all events

It's work !!!

 

Thanks a lot for your help. Here is the code if it can help anyone :

 

public boolean keyChar(char key, int status, int time){
   if ( (((String)codesBanques.elementAt(this.getSelectedIndex())==""))||(this.getSize()<=0) )
      UiApplication.getUiApplication().pushScreen(new frmEditBanque(compta));
   return super.keyChar(key,status,time);
}