yang cao
2007-Apr-14 05:29 UTC
how to simulate key_down event(when event.get_key_code()==Wx::K_DOWN) in ListCtrl or TreeCtrl?
I want to simulate vi(vim) like operations in ListCtrl or TreeCtrl, that is, for example, when user pressed a ''j'' on keyboard,the selected item change into the next one item, just like user press a Wx::K_DOWN(arrow key down on keyboard) . but not jump to some item started with a "J" charater. evt_tree_key_down(TreeTest_Ctrl) { | e | on_tree_key_down(e) } ... def on_tree_key_down(event) keycode = event.get_key_code() case keycode when 74 # ''j'' ''s keycode #what should I write here? ............... end end that''s the basic, when I know how to write, i will organize the program''s struct. thanks! cy
Alex Fenton
2007-Apr-14 10:11 UTC
[Wxruby-users] how to simulate key_down event(when event.get_key_code()==Wx::K_DOWN) in ListCtrl or TreeCtrl?
yang cao wrote:> I want to simulate vi(vim) like operations in ListCtrl or TreeCtrl, > that is, for example, when user pressed a ''j'' on keyboard,the selected > item change into the next one item, just like user press a > Wx::K_DOWN(arrow key down on keyboard) .Perhaps something like this? case event.get_key_code when ?j # correct ASCII code for ''j'' curr_sel = get_selection # what''s currently selected? return unless curr_sel if sib = get_next_sibling(curr_sel) select_item(sib) end end This only scrolls down through the TreeCtrl if the current item has another sibling - you''d need to decide whether ''j'' should move down into the current item''s children, or up into its parent''s siblings if it doesn''t. get_item_parent and get_children (which is in WxSugar) should help. alex
Possibly Parallel Threads
- [ wxruby-Bugs-6235 ] KeyEvent#get_key_code not working properly on OS X
- KeyEvent#get_key_code
- [681] trunk/wxruby2/samples/treectrl/treectrl.rb: wxMAC does not like menu id''s of 0 so I fixed that also made set_item_text_colour
- [956] branches/wxruby2/wxwidgets_282: Additions to TreeCtrl API 2.6->2.8
- doubt in Selenium test