bool dropdown_widget::handle_event(const SDL_Event& event, bool claimed) { SDL_Event ev = event; normalize_event(&ev); if(claimed) { return claimed; } if(type_ == DROPDOWN_COMBOBOX && editor_) { if(editor_->handle_event(ev, claimed)) { return true; } } if(dropdown_menu_ && dropdown_menu_->visible()) { if(dropdown_menu_->handle_event(ev, claimed)) { return true; } } if(event.type == SDL_MOUSEMOTION) { return handle_mousemotion(event.motion, claimed); } else if(event.type == SDL_MOUSEBUTTONDOWN) { return handle_mousedown(event.button, claimed); } else if(event.type == SDL_MOUSEBUTTONUP) { return handle_mouseup(event.button, claimed); } return claimed; }
bool selector_widget::handle_event(const SDL_Event& event, bool claimed) { SDL_Event ev = event; normalize_event(&ev); if(claimed) { return claimed; } if(event.type == SDL_MOUSEMOTION) { return handle_mousemotion(event.motion, claimed); } else if(event.type == SDL_MOUSEBUTTONDOWN) { return handle_mousedown(event.button, claimed); } else if(event.type == SDL_MOUSEBUTTONUP) { return handle_mouseup(event.button, claimed); } else if(event.type == SDL_KEYDOWN) { const SDL_Keycode key = event.key.keysym.sym; if(key == SDLK_LEFT || key == SDLK_PAGEUP) { select_left(); } else if(key == SDLK_RIGHT || key == SDLK_PAGEDOWN) { select_right(); } else if(key == SDLK_HOME) { if(!list_.empty()) { set_selection(0); } } else if(key == SDLK_END) { if(!list_.empty()) { set_selection(list_.size()-1); } } else if(key == SDLK_RETURN && on_select_) { on_select_(list_[current_selection_].first); } } return claimed; }
bool dropdown_widget::handle_event(const SDL_Event& event, bool claimed) { SDL_Event ev = event; switch(ev.type) { case SDL_MOUSEMOTION: { ev.motion.x -= x() & ~1; ev.motion.y -= y() & ~1; break; } case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: { ev.button.x -= x() & ~1; ev.button.y -= y() & ~1; break; } } if(claimed) { return claimed; } if(type_ == DROPDOWN_COMBOBOX && editor_) { if(editor_->handle_event(ev, claimed)) { return true; } } if(dropdown_menu_ && dropdown_menu_->visible()) { if(dropdown_menu_->handle_event(ev, claimed)) { return true; } } if(has_focus() && dropdown_menu_) { if(event.type == SDL_KEYDOWN && (ev.key.keysym.sym == controls::get_keycode(controls::CONTROL_ATTACK) || ev.key.keysym.sym == controls::get_keycode(controls::CONTROL_JUMP))) { claimed = true; dropdown_menu_->set_visible(!dropdown_menu_->visible()); } } if(event.type == SDL_MOUSEMOTION) { return handle_mousemotion(event.motion, claimed); } else if(event.type == SDL_MOUSEBUTTONDOWN) { return handle_mousedown(event.button, claimed); } else if(event.type == SDL_MOUSEBUTTONUP) { return handle_mouseup(event.button, claimed); } return claimed; }