Java Code Examples for com.codename1.ui.Display#COMMAND_BEHAVIOR_NATIVE

The following examples show how to use com.codename1.ui.Display#COMMAND_BEHAVIOR_NATIVE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlackBerryCanvas.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public Menu getMenu(int val) {
    if (Display.getInstance().getCommandBehavior() == Display.COMMAND_BEHAVIOR_NATIVE) {
        m = new Menu();
        if(commands != null){
            for (int iter = 0; iter < commands.size(); iter++) {
                final Command cmd = (Command) commands.elementAt(iter);
                String txt = UIManager.getInstance().localize(cmd.getCommandName(), cmd.getCommandName());
                MenuItem i = new MenuItem(txt, iter, iter) {
                    public void run() {
                        Display.getInstance().callSerially(new Runnable() {
                            public void run() {
                                impl.getCurrentForm().dispatchCommand(cmd, new ActionEvent(cmd));
                            }
                        });
                    }
                };
                m.add(i);
            }
        }
        return m;
    }
    return super.getMenu(val);
}
 
Example 2
Source File: BlackBerryCanvas.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public boolean onMenu(int i) {
    if(Display.getInstance().getCommandBehavior() == Display.COMMAND_BEHAVIOR_NATIVE){
        return super.onMenu(i);
    }else{
        return true;
    }
}
 
Example 3
Source File: BlackBerryCanvas.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
protected boolean keyUp(int keyCode, int time) {
    if(Keypad.key(keyCode) == Keypad.KEY_ESCAPE) {
        // prevent the browser  component from "stealing" the escape key
        impl.keyReleased(Keypad.KEY_ESCAPE);
        return true;
    }
    if (Keypad.key(keyCode) == Keypad.KEY_MENU && Display.getInstance().getCommandBehavior() != Display.COMMAND_BEHAVIOR_NATIVE) {
        if(impl.nativeEdit == null || eventTarget == null) {
            impl.keyPressed(BlackBerryImplementation.MENU_SOFT_KEY);
            impl.keyReleased(BlackBerryImplementation.MENU_SOFT_KEY);
            return true;
        }
    }
    return super.keyUp(keyCode, time);
}
 
Example 4
Source File: BlackBerryCanvas.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
protected void makeMenu(Menu menu, int instance) {
    if(Display.getInstance().getCommandBehavior() == Display.COMMAND_BEHAVIOR_NATIVE){
        menu = getMenu(instance);
        super.makeMenu(menu, instance);
    }
}
 
Example 5
Source File: BlackBerryCanvas.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
protected void onMenuDismissed(Menu arg0) {
    if(Display.getInstance().getCommandBehavior() == Display.COMMAND_BEHAVIOR_NATIVE || impl.nativeEdit != null || eventTarget != null) {
        super.onMenuDismissed(arg0);
    }
}