1

黑莓火炬表现出一些奇怪的行为。我将 EditField 子类化为仅用于视觉样式。在主应用程序中,我实例化了其中的 2 个自定义 EditField 并将样式位设置为EditField.FILTER_REAL_NUMERIC以将输入限制为数字。然后将这些 EditFields 与一些不可聚焦的标签字段一起放置在自定义 GridFieldManager 中。

如果我(在模拟器中)直接触摸这些 EditField 之一,则会显示完整的 qwerty 键盘。此时,如果我触摸任何一个没有焦点的 EditField,则会显示正确的键盘。如果我使用触控板滚动可聚焦字段,情况也是如此;显示正确的键盘。

这是一个已知问题,还是忘记了什么?

注意:我不知道这是否是 Torch 设备的问题,因为我的办公室还没有 Torch 设备。

更新: 看起来这与管理该字段的自定义 GridFieldManager 有关。此自定义代码仅用于确定焦点应该放在哪里:

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 ====================================================================================

更新 2: 我的目标是 Blackberry OS 5.0 版。

4

2 回答 2

1

用作FILTER_NUMERIC样式位。

于 2011-06-23T07:18:31.373 回答
0

问题出在 Blackberry OS 5.0 中的 GridFieldManager 上。我在这里找到了一个自定义的,直接从 子类net.rim.device.api.ui.Manager化,解决了这个问题。

于 2011-06-27T18:53:55.120 回答