int16_t NavigationPlugin::handleEvent(const ANPEvent* evt) { NPP instance = this->inst(); switch (evt->eventType) { case kDraw_ANPEventType: switch (evt->data.draw.model) { case kBitmap_ANPDrawingModel: drawPlugin(evt->data.draw.data.bitmap, evt->data.draw.clip); return 1; default: break; // unknown drawing model } break; case kLifecycle_ANPEventType: if (evt->data.lifecycle.action == kLoseFocus_ANPLifecycleAction) { gLogI.log(kDebug_ANPLogType, "----%p Loosing Focus", instance); m_hasFocus = false; inval(instance); return 1; } else if (evt->data.lifecycle.action == kGainFocus_ANPLifecycleAction) { gLogI.log(kDebug_ANPLogType, "----%p Gaining Focus", instance); m_hasFocus = true; inval(instance); return 1; } break; case kMouse_ANPEventType: return 1; case kKey_ANPEventType: if (evt->data.key.action == kDown_ANPKeyAction) { bool result = handleNavigation(evt->data.key.nativeCode); inval(instance); return result; } return 1; default: break; } return 0; // unknown or unhandled event }
uint32 NavigationScene::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { switch (messageNum) { case 0x0000: if (_interactive) sendMessage(_mouseCursor, 0x4002, param); break; case 0x0001: if (_interactive) handleNavigation(param.asPoint()); break; case 0x0009: if (!_interactive) _smackerDone = true; break; case 0x3002: _smackerDone = true; break; } return 0; }
int16_t FormPlugin::handleEvent(const ANPEvent* evt) { NPP instance = this->inst(); switch (evt->eventType) { case kDraw_ANPEventType: switch (evt->data.draw.model) { case kBitmap_ANPDrawingModel: drawPlugin(evt->data.draw.data.bitmap, evt->data.draw.clip); return 1; default: break; // unknown drawing model } break; case kLifecycle_ANPEventType: if (evt->data.lifecycle.action == kLoseFocus_ANPLifecycleAction) { gLogI.log(kDebug_ANPLogType, "----%p Loosing Focus", instance); if (m_activeInput) { // hide the keyboard gWindowI.showKeyboard(instance, false); //reset the activeInput m_activeInput = NULL; } m_hasFocus = false; inval(instance); return 1; } else if (evt->data.lifecycle.action == kGainFocus_ANPLifecycleAction) { gLogI.log(kDebug_ANPLogType, "----%p Gaining Focus", instance); m_hasFocus = true; inval(instance); return 1; } break; case kMouse_ANPEventType: { int x = evt->data.mouse.x; int y = evt->data.mouse.y; if (kDown_ANPMouseAction == evt->data.mouse.action) { TextInput* currentInput = validTap(x,y); if (currentInput) gWindowI.showKeyboard(instance, true); else if (m_activeInput) gWindowI.showKeyboard(instance, false); if (currentInput != m_activeInput) switchActiveInput(currentInput); return 1; } break; } case kKey_ANPEventType: if (evt->data.key.action == kDown_ANPKeyAction) { //handle navigation keys if (evt->data.key.nativeCode >= kDpadUp_ANPKeyCode && evt->data.key.nativeCode <= kDpadCenter_ANPKeyCode) { return handleNavigation(evt->data.key.nativeCode) ? 1 : 0; } if (m_activeInput) { handleTextInput(m_activeInput, evt->data.key.nativeCode, evt->data.key.unichar); inval(instance, m_activeInput->rect, true); } } return 1; default: break; } return 0; // unknown or unhandled event }