投稿者 トピック: [patch] スクロールリストをキーボードから操作可能にする  (参照数 4656 回)

z9999+

  • 管理人
  • 急行
  • *
  • 投稿: 381
nightlyでコンボボックスはキーボードの上下キーで操作できるようになりまし たが、なぜかスクロールリストは操作できないので、操作できるようにしました。

コード: [選択]
Index: gui/components/gui_scrolled_list.cc
===================================================================
--- gui/components/gui_scrolled_list.cc (リビジョン 3478)
+++ gui/components/gui_scrolled_list.cc (作業コピー)
@@ -172,6 +172,15 @@
  }
  }
 
+ // got to next/previous choice
+ if(  ev->ev_class == EVENT_KEYBOARD  &&  (ev->ev_code==SIM_KEY_UP  ||  ev->ev_code==SIM_KEY_DOWN)  ) {
+ int new_selection = (ev->ev_code==SIM_KEY_DOWN) ? min(item_list.get_count()-1, selection+1) : max(0, selection-1);
+ selection = new_selection;
+ show_selection(selection);
+ call_listeners((long)new_selection);
+ return true;
+ }
+
  if(sb.getroffen(x, y)  ||  IS_WHEELUP(ev)  ||  IS_WHEELDOWN(ev)) {
  event_t ev2 = *ev;
  translate_event(&ev2, -sb.get_pos().x, -sb.get_pos().y);
Index: gui/components/gui_scrolled_list.h
===================================================================
--- gui/components/gui_scrolled_list.h (リビジョン 3478)
+++ gui/components/gui_scrolled_list.h (作業コピー)
@@ -138,6 +138,8 @@
  * V.Meyer
  */
  bool action_triggered(gui_action_creator_t *komp, value_t extra);
+
+ gui_komponente_t *get_focus() const { return (gui_komponente_t *)this; }
 };
 
 #endif


z9999+

  • 管理人
  • 急行
  • *
  • 投稿: 381
r3526で動かなくなっていたので更新しました。

コード: [選択]
Index: gui/components/gui_scrolled_list.cc
===================================================================
--- gui/components/gui_scrolled_list.cc (リビジョン 3526)
+++ gui/components/gui_scrolled_list.cc (作業コピー)
@@ -24,6 +24,7 @@
 
 
 gui_scrolled_list_t::gui_scrolled_list_t(enum type type) :
+ gui_komponente_t(true),
  sb(scrollbar_t::vertical)
 {
  this->type = type;
@@ -172,6 +173,15 @@
  }
  }
 
+ // got to next/previous choice
+ if(  ev->ev_class == EVENT_KEYBOARD  &&  (ev->ev_code==SIM_KEY_UP  ||  ev->ev_code==SIM_KEY_DOWN)  ) {
+ int new_selection = (ev->ev_code==SIM_KEY_DOWN) ? min(item_list.get_count()-1, selection+1) : max(0, selection-1);
+ selection = new_selection;
+ show_selection(selection);
+ call_listeners((long)new_selection);
+ return true;
+ }
+
  if(sb.getroffen(x, y)  ||  IS_WHEELUP(ev)  ||  IS_WHEELDOWN(ev)) {
  event_t ev2 = *ev;
  translate_event(&ev2, -sb.get_pos().x, -sb.get_pos().y);


r3527で本家にマージされました。コンフリクトはありません。
« 最終編集: 2010/07/18 00:09 by z9999+ »