The Blackberry Torch is showing some wierd behaviour. I have subclassed EditField only for visual stylings. In the main application, I instantiate 2 of these custom EditFields and set the style bit to EditField.FILTER_REAL_NUMERIC
in order to limit input to numbers. These EditFields are then placed in a custom GridFieldManager along with some label fields which are un-focusable.
If I touch (in the simulator) directly on one these EditFields, the full qwerty key pad is displayed. At this point, if I touch either of the EditFields that do not have focus, the correct key pad is displayed. The same is true if I use the trackpad to scroll the focusable fields; the correct key pad is displayed.
Is this a known issue, or did forget something?
NOTE: I have no idea if this is an issue on Torch device, since my office does not yet have a Torch device.
UPDATE: It looks like this related to the custom GridFieldManager that manages this field. This custom code is only for determining where focus should go:
public ExGridFieldManager(int rows, int columns, long style) {
super(rows, columns, style );
} // END contructor -----------------------------------------------------------------
/* PROTECTED METHODS ----------------------------------------------------------------------- */
// handle focus gain on container
protected void onFocus( int direction )
{
if ( direction > 0 ) // focus came from previous field
{
for(int i = 0; i < this.getFieldCount(); i++)
{
if (this.getField(i).isFocusable())
{
this.getField(i).setFocus();
return;
}
}
}
else if ( direction < 0 ) // catch case where focus came from following field
{
for(int i = this.getFieldCount() - 1; i >= 0 ; i--)
{
if (this.getField(i).isFocusable())
{
this.getField(i).setFocus();
return;
}
}
}
} // END onFocus() ------------------------------------------------------------------
protected void paint( Graphics g ) {
super.paint(g);
} // END paint() --------------------------------------------------------------------
// catch touch on a given inside this manager and set focus appropriately
protected boolean touchEvent( TouchEvent event ) {
int index; // for holding index of field where touchEvent ocurred
if ( event.getEvent() == TouchEvent.CLICK ) {
index = this.getFieldAtLocation( event.getX(1), event.getY(1) );
if ( index > -1 )
this.getField(index).setFocus();
}
return false;
} // END touchEvent() ---------------------------------------------------------------
/* PUBLIC METHODS -------------------------------------------------------------------------- */
// determines when this manager should and should not recieve focus
public boolean isFocusable()
{
for(int i = 0; i< this.getFieldCount(); i++)
{
if (this.getField(i).isFocusable())
{
return true;
}
}
return false;
} // END isFocusable() --------------------------------------------------------------
} // END class ===========开发者_StackOverflow=========================================================================
UPDATE 2: I am targeting Blackberry OS version 5.0.
use FILTER_NUMERIC
as style bit.
The problem was with the GridFieldManager in Blackberry OS 5.0. I found a custom one here, subclassed directly from net.rim.device.api.ui.Manager
, that fixed the issue.
精彩评论