Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: wxTony.rbw Type: application/octet-stream Size: 10436 bytes Desc: not available Url : http://rubyforge.org/pipermail/wxruby-users/attachments/20040522/9c1889d0/wxTony.obj
Shashank Date wrote:> Is there a way to tab between different pages of a Notebook control.Normally, you can use Ctrl-TAB to move to the next notebook page, and Shift-Ctrl-TAB to move to the previous page. These are standard navigation keys, at least under MS Windows. This wasn''t working in your sample, apparently because of the grid control. It seems that when the grid control has the focus, it doesn''t correctly propagate those keystrokes. You can see this if you click on the "Show" button (so it has the focus), and then try Ctrl-TAB. I''m pretty sure a C++ wxWindows program would have the same problem. Based on a short look, I couldn''t see the cause of the error. I was able to work around this by adding just a little bit of code to your sample. At the end of MyFrame#initialize, I added: @grid.evt_key_down do |evt| onKeyDown(evt) end Then, I added this method in MyFrame: def onKeyDown(evt) if(evt.get_key_code == Wx::K_TAB && evt.control_down) forward = !(evt.shift_down) @m_notebook.advance_selection(forward) else evt.skip end end It appears that notebook tabs are not intended to have accelerators (like Alt-X), but I didn''t look closely. If that is important to you, I can research it more. It looks like you could catch evt_char at the notebook level, and when you get certain Alt letters you could activate specific notebook pages. Nice-looking sample, by the way. Kevin
Hi Kevin,> Normally, you can use Ctrl-TAB to move to the next notebook page, and > Shift-Ctrl-TAB to move to the previous page. These are standard > navigation keys, at least under MS Windows.Oh yes, I knew that, but did not word it correctly in my email. In fact, I was doing it so automatically that I had to convince myself that I am pressing the CTRL key, after reading your email :-)> This wasn''t working in your sample, apparently because of the grid > control. It seems that when the grid control has the focus, it doesn''t > correctly propagate those keystrokes. You can see this if you click on > the "Show" button (so it has the focus), and then try Ctrl-TAB.Correct !> I''m pretty sure a C++ wxWindows program would have the same problem. > Based on a short look, I couldn''t see the cause of the error. > > I was able to work around this by adding just a little bit of code to > your sample. At the end of MyFrame#initialize, I added: > @grid.evt_key_down do |evt| onKeyDown(evt) end > > Then, I added this method in MyFrame: > def onKeyDown(evt) > if(evt.get_key_code == Wx::K_TAB && evt.control_down) > forward = !(evt.shift_down) > @m_notebook.advance_selection(forward) > else > evt.skip > end > endExcellent .. that will work for me.> It appears that notebook tabs are not intended to have accelerators > (like Alt-X), but I didn''t look closely. If that is important to you, I > can research it more. It looks like you could catch evt_char at the > notebook level, and when you get certain Alt letters you could activate > specific notebook pages.Yes. My attempt was only in desperation. Your code shows me how to do it (event filtering, that is), so let me give it a try (if required).> Nice-looking sample, by the way.Thanks ... the GUI has been dictated by my friend who will be the only user of this app. I am only coding it as per his specs. Enjoying it in wxRuby!> KevinThanks Kevin, for the prompt response. And now, I''m going to bother you with one more (minor) irritation: I cannot seem to get the focus to the combo_box adjacent to the Account Number static text using the accelerator key ALT-A. But it works with the TextCtrl below it with ALT-C. What am I doing wrong ? Code modified with your suggestions attached. TIA, -- shanko PS> I just found out that the app works, as is, only with the latest release of one-click ruby 1.8.1 install. With the prior releases, for some reason, it does not like my idea of using :symbol.id instead of ID_SYMBOL in the calls to various constructors. -------------- next part -------------- A non-text attachment was scrubbed... Name: wxTony.rbw Type: application/octet-stream Size: 10535 bytes Desc: not available Url : http://rubyforge.org/pipermail/wxruby-users/attachments/20040522/114b1222/wxTony-0001.obj
Shashank Date wrote:> Thanks Kevin, for the prompt response. And now, I''m going to bother you > with one more (minor) irritation: > > I cannot seem to get the focus to the combo_box adjacent to the Account > Number static text using the accelerator key ALT-A. But it works with the > TextCtrl below it with ALT-C. What am I doing wrong ?This is difficult for me to test, because the GTK version of wxWindows doesn''t seem to support accelerators anywhere other than menu items. When I run your sample (on my Linux box), neither Alt-A nor Alt-C have any effect. However, I can take a guess at what might be causing the problem you describe: You create the Customer static control *before* the TextCtrl, but you create the Account static text *after* the combo box. If you create the label before the combo box, it just might work. If not, perhaps someone else with MS Windows can help diagnose it.> PS> I just found out that the app works, as is, only with the > latest release of one-click ruby 1.8.1 install. With the prior > releases, for some reason, it does not like my idea of using > :symbol.id instead of ID_SYMBOL in the calls to various constructors.Strange that it doesn''t work with earlier ruby versions. I can''t think of why that would be the case. Interesting approach (using :label.id instead of ID_LABEL). Personally, I tend to pass -1 in the constructor, to allow wxRuby to assign some id, and then label.get_id later when I need to use it. Cheers, Kevin
Kevin,> However, I can take a guess at what might be causing the problem you > describe: You create the Customer static control *before* the TextCtrl, > but you create the Account static text *after* the combo box. If you > create the label before the combo box, it just might work.Yes, it did ! I am not yet used to "creation-order = tab-order" mindset (and spent quite a deal of time searching for a way to set tab order before reading the wxWidgets help).> Interesting approach (using :label.id instead of ID_LABEL).Learnt it from one of the examples that came with wxRuby :-)> Personally, > I tend to pass -1 in the constructor, to allow wxRuby to assign some id, > and then label.get_id later when I need to use it.I did not know we could do that. I like your idea better. Thanks, -- shanko
I am trying to understand the behaviour of ComboBox control and its interaction with a Button. Please see attached example. Some how I cannot seem to capture the contents of the Combo in the ButtonClick event if I enter text which is not in the choices. Also, what do the following methods do: 1.. get_client_data 2.. get_count Thanks, -- shanko -------------- next part -------------- A non-text attachment was scrubbed... Name: tst_combo.rb Type: application/octet-stream Size: 2482 bytes Desc: not available Url : http://rubyforge.org/pipermail/wxruby-users/attachments/20040523/6271b692/tst_combo.obj
Shashank Date wrote:> Some how I cannot seem to capture the contents of the Combo > in the ButtonClick event if I enter text which is not in the choices.Your sample calls get_string_selection, but that method returns the currently-selected list item as a string. It won''t return anything that isn''t in the list. If the user types a value into the text box, get_string_selection will still return whatever item in the list had previously been selected. You really want to call get_value. Unfortunately, that''s not implemented in wxRuby 0.3.0. On my local machine, I added code to support get_value, and it worked. Unfortunately, this machine can''t check the change into CVS and the darcs repo. I will try to make the change on my other machine and get it checked in. At that point, you could build wxRuby from CVS or a tarball, and have get_value available. We don''t yet know when the next release of wxRuby will happen. When it does (whether that release is swig-based or not), it should include support for ComboBox#get_value.> Also, what do the following methods do: > 1.. get_client_dataRight now, it probably causes a crash, due to known memory management problems. It is supposed to return whatever value you passed to set_client_data.> 2.. get_countIt should return the number of items in the list. Kevin
Hi Kevin,> I will try to make the change on my other machine and get it > checked in. At that point, you could build wxRuby from CVS > or a tarball, and have get_value available.Great ! Please let me know when it gets checked in. Mean while, is there a work around ? Using some event handling magic ? Let me think ... -- shanko
> You really want to call get_value. Unfortunately, that''s not implemented > in wxRuby 0.3.0.I found to my surprise that this method is actually working, but only in the example code that comes with wxRuby one-click install for Windows. If you see lines 787-790 in \wxRuby\samples\controls\controls.rbw: def onComboTextEnter(event) log_message("Enter pressed in the combobox: value is ''%s''.", @m_combo.get_value()) end And I could see that the string entered was being shown in the log window. Is that because of the customized version of ComboBox (i.e. MyComboBox)? Cool ! -- shanko
Shashank Date wrote:> I found to my surprise that this method is actually working, but only in the > example code that comes with wxRuby one-click install for Windows. > > If you see lines 787-790 in \wxRuby\samples\controls\controls.rbw: > > def onComboTextEnter(event) > log_message("Enter pressed in the combobox: value is ''%s''.", > @m_combo.get_value()) > endWhen I run that sample using wxRuby 0.3.0, and I press Enter while in the combobox, I get a ruby exception for method not found: get_value. Kevin
Kevin Smith wrote:> Shashank Date wrote: > >> I found to my surprise that this method is actually working, but only >> in the >> example code that comes with wxRuby one-click install for Windows. >> >> If you see lines 787-790 in \wxRuby\samples\controls\controls.rbw: >> >> def onComboTextEnter(event) >> log_message("Enter pressed in the combobox: value is ''%s''.", >> @m_combo.get_value()) >> end > > > When I run that sample using wxRuby 0.3.0, and I press Enter while in > the combobox, I get a ruby exception for method not found: get_value.As you hit each key, it is able to print the entire contents string because the evt_text event for the combo box includes it. For a cross-platform workaround, I suppose you could catch this event, and keep a local copy of the current string yourself. Where you would have called get_value, just refer to this copy. Kevin