Search in sources :

Example 1 with Canvas

use of javax.microedition.lcdui.Canvas in project J2ME-Loader by nikita36078.

the class MicroActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (current != null) {
        int id = item.getItemId();
        if (item.getGroupId() == R.id.action_group_common_settings) {
            if (id == R.id.action_exit_midlet) {
                showExitConfirmation();
            } else if (current instanceof Canvas && ContextHolder.getVk() != null) {
                VirtualKeyboard vk = ContextHolder.getVk();
                switch(id) {
                    case R.id.action_layout_edit_mode:
                        vk.switchLayoutEditMode(VirtualKeyboard.LAYOUT_KEYS);
                        break;
                    case R.id.action_layout_scale_mode:
                        vk.switchLayoutEditMode(VirtualKeyboard.LAYOUT_SCALES);
                        break;
                    case R.id.action_layout_edit_finish:
                        vk.switchLayoutEditMode(VirtualKeyboard.LAYOUT_EOF);
                        break;
                    case R.id.action_layout_switch:
                        vk.switchLayout();
                        break;
                    case R.id.action_hide_buttons:
                        showHideButtonDialog();
                        break;
                }
            }
            return true;
        }
        CommandListener listener = current.getCommandListener();
        if (listener == null) {
            return false;
        }
        for (Command cmd : current.getCommands()) {
            if (cmd.hashCode() == id) {
                current.postEvent(CommandActionEvent.getInstance(listener, cmd, current));
                return true;
            }
        }
    }
    return super.onOptionsItemSelected(item);
}
Also used : CommandListener(javax.microedition.lcdui.CommandListener) Command(javax.microedition.lcdui.Command) Canvas(javax.microedition.lcdui.Canvas) VirtualKeyboard(javax.microedition.lcdui.pointer.VirtualKeyboard)

Aggregations

Canvas (javax.microedition.lcdui.Canvas)1 Command (javax.microedition.lcdui.Command)1 CommandListener (javax.microedition.lcdui.CommandListener)1 VirtualKeyboard (javax.microedition.lcdui.pointer.VirtualKeyboard)1