When operating with a wxGrid is there a way to get a reference to the TextCtrl field that is created when you start typing in a cell. Also is there a way to get mouse events to work with a wxGrid, so far I can''t get any of them to work. I had tried various combo''s of: @grid.evt_left_down(){ |event| puts "Left mouse is down"; } using evt_left_down, evt_left_up, evt_mouse_events, etc... Thanks, Zach --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/13/2004
> When operating with a wxGrid is there a way to get a reference to the > TextCtrl field that is created when you start typing in a cell.> Also is there a way to get mouse events to work with a wxGrid, so farI> can''t get any of them to work. I had tried various combo''s of:Could you please post an example code on how you create the grid? I can''t seem to get a Grid to show, even though it''s there. (See sample code). wxRuby 0.3, Ruby 1.8.1, WinXP. Cheers, Assaph ------ CODE ------ require ''wxruby'' include Wx ID_GRID = 1 ID_BTN1 = 2 ID_BTN2 = 3 class TestFrame < Frame def initialize super(nil, -1, "Test App") dlgSizer = BoxSizer.new(VERTICAL) @grid = Grid.new(self, ID_GRID) @grid.create_grid(5, 3) @grid.set_cell_value(0, 0, "wxGrid is good" ); dlgSizer.add(@grid, 1, ALL, 3) @btn_test = Button.new(self, ID_BTN2, "Test Me") evt_button(ID_BTN2) { on_btn_test } dlgSizer.add(@btn_test, 1, ALIGN_RIGHT | ALL, 3) dlgSizer.set_size_hints(self) set_sizer(dlgSizer) set_size(Size.new(600,300)) layout() end def on_btn_test MessageDialog.new(self, "Cell 0:0 - #{@grid.get_cell_value(0,0).inspect}", "Cell Value").show_modal end end class TestApp < App def on_init frm = TestFrame.new set_top_window(frm) frm.centre(BOTH) frm.show(true) end end TestApp.new.main_loop
Hi Assaph, ----- Original Message ----- From: "Mehr, Assaph (Assaph)" <assaph@avaya.com>> Could you please post an example code on how you create the grid? > I can''t seem to get a Grid to show, even though it''s there. (See sample > code). > > wxRuby 0.3, Ruby 1.8.1, WinXP. >This worked for me (same platform as above): #-------------------------------------------------- require ''wxruby'' include Wx ID_GRID = 1 ID_BTN1 = 2 ID_BTN2 = 3 class TestFrame < Frame def initialize super(nil, -1, "Test App") dlgSizer = BoxSizer.new(VERTICAL) @grid = Grid.new(self, ID_GRID, Point.new(50,50), Size.new(325,135)) @grid.create_grid(5, 3) @grid.set_cell_value(0, 0, "wxGrid is good" ); dlgSizer.add(@grid, 1, ALL, 3) @btn_test = Button.new(self, ID_BTN2, "Test Me", Point.new(5,5) ) evt_button(ID_BTN2) { on_btn_test } dlgSizer.add(@btn_test, 1, ALIGN_RIGHT | ALL, 3) dlgSizer.set_size_hints(self) set_sizer(dlgSizer) set_size(Size.new(600,300)) layout() end def on_btn_test MessageDialog.new(self, "Cell 0:0 - #{@grid.get_cell_value(0,0).inspect}", "Cell Value").show_modal end end class TestApp < App def on_init frm = TestFrame.new set_top_window(frm) frm.centre(BOTH) frm.show(true) end end TestApp.new.main_loop
>> Could you please post an example code on how you create the grid? >> I can''t seem to get a Grid to show, even though it''s there. (Seesample>> code). >> >> wxRuby 0.3, Ruby 1.8.1, WinXP.> This worked for me (same platform as above):Strange. Seems like the (implied) DEFAULT_SIZE in the constructor is taken to mean zero size. This c''tor seems to fix that: Grid.new(self, ID_GRID, DEFAULT_POSITION, Size.new(400,200)). Anyway, to the problem at hand. Seems like the (c++) documented event handlers for wxGrid (all the evt_grid_*) are unimplemented in the wxruby 0.3. At least I couldn''t find them. Looking over Zach''s original post, there may be work arounds:> When operating with a wxGrid is there a way to get a reference to the > TextCtrl field that is created when you start typing in a cell.The EVT_GRID_EDITOR_* are unimplemented. You can however respond by using: @grid.evt_key_down { |evt| on_grid_key_down(evt) } And filter the keys until you get an ''enter''. Seems that when you start typing in a cell you get a KeyEvent with the first char, and when you press enter you get a second event with key code of 13. Will that help?> Also is there a way to get mouse events to work with a wxGrid, so farI> can''t get any of them to work. I had tried various combo''s of:Tried but couldn''t get them to work either... :( Seems like the Grid is not propagating the mouse events. When I added: @grid.set_event_handler(self) And changed the events accordingly to: evt_key_down { |evt| on_grid_key_down(evt) } evt_left_down { |evt| evt_left_dclick(evt) } all the key events did go through the Frame handler, but the mouse events weren''t. In fact double clicking on a cell created the cell-editor, but pressing ''enter'' in the cell went to the Frame handler... Guess this will have to wait to Kevin. Zach, what are you trying to do? Can you find a workaround with implemented events? HTH, Assaph
Mehr, Assaph (Assaph) wrote:>>>Could you please post an example code on how you create the grid?The new "official" grid sample, which will be part of the next release, is here: http://qualitycode.com/repos/wxruby/samples/grid/grid.rb> Guess this will have to wait to Kevin.Yes, and it will have to wait for the swig version, unfortunately. I just can''t see investing hours implementing grid features in this version, because all that work would be thrown away in a month or two anyway. Hopefully you can find some workarounds for now. I know this is a frustrating situation. I''ll try to work on the swig version as soon and as much as I can. Cheers, Kevin
> The new "official" grid sample, which will be part of the nextrelease,> is here: > http://qualitycode.com/repos/wxruby/samples/grid/grid.rbThanks, but it doesn''t show events... One of these days I should really sit down and write one for ListCtrl.>> Guess this will have to wait to Kevin.> Yes, and it will have to wait for the swig version, unfortunately. I > just can''t see investing hours implementing grid features in this > version, because all that work would be thrown away in a month or two > anyway.> Hopefully you can find some workarounds for now. I know this is a > frustrating situation. I''ll try to work on the swig version as soonand> as much as I can.Dude, we''re all grateful for the excellent library! All your effort are highly appreciated. We know you have constraints on your time, that''s why I was trying to help find a work around.
> Dude, we''re all grateful for the excellent library! All your effort are > highly appreciated. We know you have constraints on your time, that''s > why I was trying to help find a work around.Thanks for this, and the other positive comments I have gotten. Mostly, I''m just frustrated with myself for not having more time to put into this. Fortunately, my move should improve things... Blissfully, Kevin
Assaph wrote:>Seems like the Grid is not propagating the mouse events. When I added: > @grid.set_event_handler(self) >And changed the events accordingly to: > evt_key_down { |evt| on_grid_key_down(evt) } > evt_left_down { |evt| evt_left_dclick(evt) } > >all the key events did go through the Frame handler, but the mouse >events weren''t. In fact double clicking on a cell created the >cell-editor, but pressing ''enter'' in the cell went to the Frame >handler...I can get the key events to be handled by the frame or grid. @frame.evt_key_down works @grid.evt_key_down works I cannot get any mouse events to work for the grid or the frame.> >Zach, what are you trying to do? Can you find a workaround with >implemented events? >I am already using the evt_key_down workarounds to do what I need to do, but it isn''t how I''d like to do it. I am working on a miniSpreadsheet app. When a user starts to enter a formula by entering a equals sign into the cell, I would like my app to know that it is in an equation, so whenever the user clicks on another cell it adds the cell position/label to my cell with the equation. I don''t want my cell to lose focus or to lose it''s textctrl field while it is in "equation/formula" mode. I thought if there was a way to reference the TextCtrl field then I could force it to stay up while it''s in equation/formula mode, then I could manually destory the textctrl field when the user hit enter, or ASCII 13. I hope I''m making sense, because I am working on this on my laptop at home which doesn''t have internet. Much like Kevin is moving, I just moved and I have a tv, a chair and my laptop. ;) My computer at work doesn''t have wxRuby so I''ve been putting the wxRuby documentation and source to cd and then taking it home to my laptop, where I read it. And by the time I have a question (no i don''t write them down, i know i should) I just try to remember it for when I get to work the next day. I think Kevin has done a hell of a job with wxRuby and I applaud what he is doing. If you ever get bogged down and could use some help don''t hesitate to ask. If I can assist anything your doing just let me know and I''m sure there are others who feel the same way. Good luck moving Kevin! Zach --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 5/13/2004
> I can get the key events to be handled by the frame or grid. > @frame.evt_key_down works > @grid.evt_key_down works> I cannot get any mouse events to work for the grid or the frame.I assume that you call the event handlers from the YourFrame#initialize method, and that the @frame above is just for notation. I did get the mouse events working in the frame, as long as you don''t click on the grid the event will be processed. I understand the problem you described. Unfrtunately I don''t see a solution currently. What you can do is keep it as a keyboard-only spreadsheet (call it a feature :), and let the user mark the cells he needs by moving and selecting with the arrow + meta keys. This might allow you to continue development until the next generation of wxRuby (SWIG based) is released. HTH, Assaph ps. From this post and from clr I gather you''re working on the practical language demo, right? I''ll be glad to help.
Zach Dennis wrote:> I cannot get any mouse events to work for the grid or the frame.I fiddled with this a bit, and couldn''t see any way to do it with the existing grid class. Bummer.> I thought if there was a way to reference the TextCtrl field then I could > force it to stay up while it''s in equation/formula mode, then I could > manually destory the textctrl field when the user hit enter, or ASCII 13.One thought I had was to prevent the built-in editor from coming up, and to just dynamically construct a standard TextCtrl in the proper place at the proper time. But this still wouldn''t disable the mouse clicks that are being caught directly by the grid.> If I can assist anything your doing just let me know and I''m sure there > are others who feel the same way.At this point, things people could do to help wxruby would be: 1. Help with getting wxruby-swig building on Windows 2. Better samples (consistent style, obvious functionality) 3. How-tos, tutorials, other documentation 4. Review all the wxPython methods and see if any are inappropriate for wxRuby That''s all I can think of right now. Once wxruby-swig starts to get closer, I will definitely be able to use more help. > Good luck moving Kevin! Thanks. I''m mostly packed, and just have to sell off some furniture and wrap up a project at work. If you happen to live along I-10 between California and Florida, and especially if you are near Palm Springs CA, Las Cruces NM, or Gulfport MS, let me know off-list[1]. I plan to spend one night in each of those cities between June 16 and 20. It''s always fun to meet internet people in meatspace[2]. Kevin [1] wxruby at qualitycode.com [2] http://www.usemod.com/cgi-bin/mb.pl?MeatSpace
> At this point, things people could do to help wxruby would be: > 1. Help with getting wxruby-swig building on WindowsI can try, if you give me a detailed instruction list. I am working on MSVC for a living, but have never tried the wxWidgets code.> 2. Better samples (consistent style, obvious functionality) > 3. How-tos, tutorials, other documentation > 4. Review all the wxPython methods and see if any are inappropriatefor wxRuby One of these days I''ll get to it...> If you happen to live along I-10 between California and Florida, and > especially if you are near Palm Springs CA, Las Cruces NM, or Gulfport> MS, let me know off-list[1]. I plan to spend one night in each ofthose> cities between June 16 and 20. It''s always fun to meet internet people> in meatspace[2].If you drive past Sydney, Australia, there are a couple of nice pubs around :-) Cheers, Assaph
Mehr, Assaph wrote:> > > At this point, things people could do to help wxruby would be: > > 1. Help with getting wxruby-swig building on Windows > > I can try, if you give me a detailed instruction list. I am working on > MSVC for a living, but have never tried the wxWidgets code.Download the latest tarball from: http://qualitycode.com/repos/wxruby-swig/ then generally follow the non-swig build instructions in README.mswin. There will, most likely be some changes needed in the build instructions for the swig version, so keep track of things that you have to do differently. I''m trying to do this also, but at the moment my available time is *extremely* limited. In fact if you could post problems and solutions as you go it would help me avoid redoing the same work (since you are very likely to get ahead of me in this process). Curt
Curt Hibbs wrote:> Mehr, Assaph wrote: > >>I can try, if you give me a detailed instruction list. I am working on >>MSVC for a living, but have never tried the wxWidgets code. > > Download the latest tarball from: > > http://qualitycode.com/repos/wxruby-swig/ > > then generally follow the non-swig build instructions in README.mswin.Hmmm. That''s not what I would have said. Yes, grab the latest tarball from the above location. Then, you should install rubygems if you haven''t already: http://rubyforge.org/projects/rubygems/ That should allow you to easily install rake: http://rubyforge.org/projects/rake After you unpack the wxruby-swig tarball, you should just be able to run ''rake'' from the main directory. You don''t run make configure, or make. At that point, it''s just a matter of figuring out, and either reporting or fixing, any compiler or linker warnings or errors. That''s where the old non-swig build instructions will help. Thanks, Kevin
Kevin Smith wrote:> > Curt Hibbs wrote: > > Mehr, Assaph wrote: > > > >>I can try, if you give me a detailed instruction list. I am working on > >>MSVC for a living, but have never tried the wxWidgets code. > > > > Download the latest tarball from: > > > > http://qualitycode.com/repos/wxruby-swig/ > > > > then generally follow the non-swig build instructions in README.mswin. > > Hmmm. That''s not what I would have said. > > Yes, grab the latest tarball from the above location. Then, you should > install rubygems if you haven''t already: > http://rubyforge.org/projects/rubygems/ > > That should allow you to easily install rake: > http://rubyforge.org/projects/rake > > After you unpack the wxruby-swig tarball, you should just be able to run > ''rake'' from the main directory. You don''t run make configure, or make. > > At that point, it''s just a matter of figuring out, and either reporting > or fixing, any compiler or linker warnings or errors. That''s where the > old non-swig build instructions will help.Thanks for correcting me (its been a while since I did anything with the swig version). I guess I was thinking of the readme for the instructions on building wxWidgets, and also I was in the old mindset because I''m using what little extrat time I have to get ready to build the 0.4.0 release for windows. Curt