// __________________________________________________________________________________________________ bool KikiPageText::handleKey ( const KKey & key ) { bool retval = false; std::string keyName = key.getUnmodifiedName (); if (keyName == "DOWN" || keyName == "PAGEDOWN" || keyName == "RIGHT" || keyName == "RETURN" || keyName == "SPACE") { if (getEventWithName ("next")) { Controller.sound->playSound (KikiSound::MENU_SELECT); startTimedAction (getActionWithId (ACTION_NEXT_PAGE)); } else { KikiEvent * prevEvent = getEventWithName ("previous"); if (prevEvent) { events.erase (std::find (events.begin(), events.end(), prevEvent)); delete prevEvent; } Controller.sound->playSound (KikiSound::MENU_ABORT); Controller.timer_event->addAction (getActionWithId (ACTION_HIDE)); } retval = true; } else if (keyName == "UP" || keyName == "PAGEUP" || keyName == "LEFT") { if (getEventWithName ("previous")) { Controller.sound->playSound (KikiSound::MENU_SELECT); startTimedAction (getActionWithId (ACTION_PREVIOUS_PAGE)); } retval = true; } else { if (keyName == "ESCAPE") retval = true; KikiEvent * nextEvent = getEventWithName ("next"); if (nextEvent) { events.erase (std::find (events.begin(), events.end(), nextEvent)); delete nextEvent; } KikiEvent * prevEvent = getEventWithName ("previous"); if (prevEvent) { events.erase (std::find (events.begin(), events.end(), prevEvent)); delete prevEvent; } Controller.sound->playSound (KikiSound::MENU_ABORT); Controller.timer_event->addAction (getActionWithId (ACTION_HIDE)); } return retval; }
// __________________________________________________________________________________________________ bool KikiScrollMenu::handleKey ( const KKey & key ) { std::string keyName = key.getUnmodifiedName (); if (keyName == "LEFT" || keyName == "RIGHT") { active_index += ((keyName == "LEFT") ? -1 : 1) * num_rows; if (circular) { if (active_index < 0) active_index += (int)all_menu_items.size(); else if ((active_index) >= (int)all_menu_items.size()) active_index -= (int)all_menu_items.size(); } else { if (active_index < 0) { offset = index_offset = active_index = 0; } else { active_index = kMin(all_menu_items.size()-1, active_index); } } activeIndexChanged (); getEventWithName ("changed")->triggerActions(); } else { return KikiMenu::handleKey (key); } return true; }
// __________________________________________________________________________________________________ bool KikiController::handleKey ( const KKey & key ) { //KConsole::printf("KikiController::handleKey %s", key.name.c_str()); if (key.getUnmodifiedName() == "ESCAPE") { events[ESCAPE_KEY_EVENT]->triggerActions(); return true; } if (key.name == quit_key) { SDL_Event event; event.type = SDL_QUIT; SDL_PushEvent (&event); return true; } if (key.name == "F9") { debug_version = !debug_version; KConsole::printf("toggle debug mode"); if (debug_version) SDL_ShowCursor (SDL_ENABLE); else SDL_ShowCursor (SDL_DISABLE); return true; } if (isDebugVersion()) { if (key.name == "e") { world->setEditMode (!world->getEditMode()); return true; } if (key.name == "f") { world->focusOnPickedPickable(); return true; } if (key.name == "b") { world->setDisplayBorder (!world->flags[KikiWorld::DISPLAY_BORDER]); return true; } if (key.name == "r") { world->setDisplayRaster (!world->flags[KikiWorld::DISPLAY_RASTER]); return true; } if (key.name == "d") { world->flags[KikiWorld::DISPLAY_DOTS] = !world->flags[KikiWorld::DISPLAY_DOTS]; world->debug_cells = !world->debug_cells; return true; } if (key.name == "c") { KConsole::getConsole()->show(); } } if (key.character >= '1' && key.character <= '9') { speed = key.character - '0'; return true; } //if (key.name == "c") { KConsole::getConsole()->clear(); return true; } return false; }