开发者

How do change listeners work

开发者 https://www.devze.com 2023-03-12 05:25 出处:网络
I regularly see the following code in blackberry development. It registers a listener on a field and when the listener is fired(in below example when focus is on a field) some code is executed. Is thi

I regularly see the following code in blackberry development. It registers a listener on a field and when the listener is fired(in below example when focus is on a field) some code is executed. Is this part 开发者_运维问答of a design pattern? How is focusChanged actually called ?

    FocusChangeListener focusListener = new FocusChangeListener() {

            public void focusChanged(Field field, int eventType) {
                // TODO Auto-generated method stub

            }

    }
    field.setFocusListener(focusListener);


Focus change is called by the OS, or some BB APIs that sit close to the OS. Whenever someone scrolls through, or touches a field the focus changes. Think of it kind of like tabbing through a window in a desktop app.

As you move through the controls, your app gets notified of the focus change, which notifies your base manager, and it bubbles up until it gets handled.

Similarly for ButtonClickListener etc. They're basically events that get fired (to think of it in the Windows parlance) and the ChangeListeners that subscribe to those events get called.

0

精彩评论

暂无评论...
验证码 换一张
取 消