I am attempting to create a scrollable panel. This works fine for using the scroll arrows, as I am capturing the event and then incrementing the scroll pos by the desired amount. However, it is not working on thumbtracking. I capture the event successfully, but I am unable to capture the position of the thumb tracker. I have looked at the poor man''s doc and have been unable to figure out how this is captured. I have also looked at the wxWidgets documentation and tried using event.get_position (corresponding to wxWidgets GetPosition, and following the format generally used in wxRuby), but this was not successful. Thanks, Joe _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
Hi Joe Firstly, please tell us what version of wxruby you are using, and what platform.> I am attempting to create a scrollable panel. This works fine for > using the scroll arrows, as I am capturing the event and then > incrementing the scroll pos by the desired amount. However, it is not > working on thumbtracking.My guess is that it''s because the relevant event class (are you expecting a ScrollWinEvent?) is not yet ported from WxWidgets to wxruby in the version you''re using.> I capture the event successfully, but I am unable to capture the > position of the thumb tracker.If the event handler is firing correctly, I''d suggest doing a simple ''p evt'' in your event handler method to tell you what sort of event you received. If as I suspect the relevant Event class is missing, it''ll say something like: <Wx::Event ....> This is a stub generic event, but it won''t have any useful methods to find the position of the event etc.> I have also looked at the wxWidgets documentation and tried using > event.get_position (corresponding to wxWidgets GetPosition, and > following the format generally used in wxRuby), but this was not > successful.The method name is right, but it''s probably just missing. If you post a little sample code, we can check if it works or not in the current development branch. If it''s missing, please feel free to submit a feature request for this. I expect it could be pretty easily added, but no-one among the wxruby developers has yet needed this method. Hope this helps alex
Alex, Thanks for your response. Here is the bit of code that is actually affected. # Here is where the thumbtrack event is being captured @panel.evt_scrollwin_thumbtrack(){|event| on_thumbtrack(event)} # Here is the function to update the scroll position based off of the current thumb position def on_thumbtrack(event) @panel.set_scroll_pos(VERTICAL, event.get_position()) end I did check the event type with a p event in the on_thumbtrack function like you suggested. It did return a generic Wx::Event, rather than the desired Wx::ScrollWinEvent. I am currently using the wxRuby 0.6.0 release on Windows. Thanks, Joe On 8/3/06, Alex Fenton <alex at pressure.to> wrote:> > Hi Joe > > Firstly, please tell us what version of wxruby you are using, and what > platform. > > I am attempting to create a scrollable panel. This works fine for > > using the scroll arrows, as I am capturing the event and then > > incrementing the scroll pos by the desired amount. However, it is not > > working on thumbtracking. > My guess is that it''s because the relevant event class (are you > expecting a ScrollWinEvent?) is not yet ported from WxWidgets to wxruby > in the version you''re using. > > I capture the event successfully, but I am unable to capture the > > position of the thumb tracker. > If the event handler is firing correctly, I''d suggest doing a simple ''p > evt'' in your event handler method to tell you what sort of event you > received. If as I suspect the relevant Event class is missing, it''ll say > something like: > > <Wx::Event ....> > > This is a stub generic event, but it won''t have any useful methods to > find the position of the event etc. > > I have also looked at the wxWidgets documentation and tried using > > event.get_position (corresponding to wxWidgets GetPosition, and > > following the format generally used in wxRuby), but this was not > > successful. > The method name is right, but it''s probably just missing. If you post a > little sample code, we can check if it works or not in the current > development branch. If it''s missing, please feel free to submit a > feature request for this. I expect it could be pretty easily added, but > no-one among the wxruby developers has yet needed this method. > > Hope this helps > alex > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20060804/baa91555/attachment.html
Hi Joe I''m afraid it looks like you won''t be able to do what you want to do with the 0.6.0 version of wxruby, since the event type isn''t supported. I tried adding support for ScrollWinEvents to wxruby2 this afternoon and it looks to work well. But - we''ve got a short-term freeze on adding new stuff to wxruby2 until we''ve committed outstanding patches to CVS and released an alpha. So I don''t think I can add this to wxruby2 straight away. I''ve not used Wx::ScrolledWindow, so what would be very helpful, if you''re able, is a short, self-contained ruby script that demonstrates the use of evt_scrollwin_thumbtrack etc. That would help me confirm that the functions work as they ought to, and get support for the functions you want into the second release of wxruby2. Thanks alex Joe Seeley wrote:> Alex, > > Thanks for your response. Here is the bit of code that is actually > affected. > > # Here is where the thumbtrack event is being captured > @panel.evt_scrollwin_thumbtrack(){|event| on_thumbtrack(event)} > > # Here is the function to update the scroll position based off of the > current thumb position > def on_thumbtrack(event) > @panel.set_scroll_pos(VERTICAL, event.get_position()) > end > > I did check the event type with a p event in the on_thumbtrack > function like you suggested. It did return a generic Wx::Event, > rather than the desired Wx::ScrollWinEvent. > > I am currently using the wxRuby 0.6.0 release on Windows. >
Alex, I whipped up a little script today that should show the different scroll events in action. # BEGIN CODE =begin rdoc ===Author: Joiey Seeley ===Description: This is a test class to demonstrate usage of scroll window events =end require ''wxruby'' include Wx class MainFrame < Frame def initialize(title) super(nil, -1, ''Thumb Scrolling Test'', Point.new(-1,-1), Size.new(1024, 487), style=SYSTEM_MENU | CAPTION | RESIZE_BORDER | 0 | 0 | MAXIMIZE_BOX | MINIMIZE_BOX | VERTICAL) set_scrollbar(VERTICAL, 0, 2000, 5000) @panel = Panel.new(self, -1) @addSrcButton = Button.new(@panel, -1, ''Add File'', Point.new(200,200), Size.new(125, 20)) @addSrcButton.set_background_colour(Colour.new(212, 208, 200)) @addSrcButton.set_foreground_colour(Colour.new(0, 0, 0)) @addSrcButton.set_font(Font.new(8.25, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL, FALSE, ''Microsoft Sans Serif'')) @addSrcButton.enable(true) # The following two work since they are not dependent on the event being of type Wx::ScrollWinEvent evt_scrollwin_linedown(){|event| on_line(event,20)} evt_scrollwin_lineup(){|event| on_line(event,-20)} # The followin events do not work correctly since they are dependent on the event being of type Wx::ScrollWinEvent evt_scrollwin_thumbtrack(){|event| on_thumb(event)} evt_scrollwin_thumbrelease(){|event| on_thumb(event)} # The following events don''t appear to be generated ever evt_scrollwin_pagedown(){|event| on_page(event,1)} evt_scrollwin_pageup(){|event| on_page(event,-1)} evt_scrollwin_top(){|event| on_top(event)} evt_scrollwin_bottom(){|event| on_bottom(event)} end # Should move to the bottom of the window (Assuming this should be triggered when the End key is pressed) def on_bottom(event) set_scroll_pos(VERTICAL, 3000) @panel.move(Point.new(@panel.get_position.x,3000)) end # Should move to the bottom of the window (Assuming this should be triggered when the Home/Begin key is pressed) def on_top(event) set_scroll_pos(VERTICAL, 0) @panel.move(Point.new(@panel.get_position.x,0)) end # Scrolls the window up/down def on_line(event,y_off) set_scroll_pos(VERTICAL, get_scroll_pos(VERTICAL)+y_off) @panel.move(Point.new(@panel.get_position.x,@ panel.get_position.y-y_off)) end # Should scroll the window up/down proportionally to the location of the thumb. def on_thumb(event) y_off = @panel.get_position.y - event.get_position.y set_scroll_pos(VERTICAL, get_scroll_pos(VERTICAL)+y_off) @panel.move(Point.new(@panel.get_position.x,event.get_position.y)) end end #--------------------------------------------------------------------------- class TSTGui < App def on_init frame = MainFrame.new('''') frame.show(TRUE) end end app = TSTGui.new app.main_loop # END CODE Thanks, Joe On 8/7/06, Alex Fenton <alex at pressure.to> wrote:> > Hi Joe > > I''m afraid it looks like you won''t be able to do what you want to do > with the 0.6.0 version of wxruby, since the event type isn''t supported. > > I tried adding support for ScrollWinEvents to wxruby2 this afternoon and > it looks to work well. But - we''ve got a short-term freeze on adding new > stuff to wxruby2 until we''ve committed outstanding patches to CVS and > released an alpha. So I don''t think I can add this to wxruby2 straight > away. > > I''ve not used Wx::ScrolledWindow, so what would be very helpful, if > you''re able, is a short, self-contained ruby script that demonstrates > the use of evt_scrollwin_thumbtrack etc. That would help me confirm that > the functions work as they ought to, and get support for the functions > you want into the second release of wxruby2. > > Thanks > alex > > > > Joe Seeley wrote: > > Alex, > > > > Thanks for your response. Here is the bit of code that is actually > > affected. > > > > # Here is where the thumbtrack event is being captured > > @panel.evt_scrollwin_thumbtrack(){|event| on_thumbtrack(event)} > > > > # Here is the function to update the scroll position based off of the > > current thumb position > > def on_thumbtrack(event) > > @panel.set_scroll_pos(VERTICAL, event.get_position()) > > end > > > > I did check the event type with a p event in the on_thumbtrack > > function like you suggested. It did return a generic Wx::Event, > > rather than the desired Wx::ScrollWinEvent. > > > > I am currently using the wxRuby 0.6.0 release on Windows. > > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20060809/29822b85/attachment.html
Hi Joe Joe Seeley wrote:> I whipped up a little script today that should show the different > scroll events in action.Thank you very much for the test script. It didn''t work quite as expected - on my machine it didn''t show a scroll bar to test. I''m not sure what this is down to - it could be a few things. My hunch is it''s because OS X doesn''t allow arbitrary-sized buttons, and probably not arbitrary scrollbars - it is stricter about UI guidelines. Anyway I adapted your sample to the attached scrollwin.rb, which uses the Wx::ScrolledWindow class. Then I used it to test adding ScrollWinEvent to wxruby2. It all seems to work well - though I can''t figure out how evt_scrollwin_top is supposed to be generated? The attached patch and .i file adds support for ScrollWinEvent and event handlers to wxruby2. People - sorry for adding to the backlog, but would be nice if we could squeeze this into alpha1. It''s a little patch, seems a fairly core class, and ScrolledWindow is already in there. Might need to up your ''fuzz'' settings when appying this patch. cheers alex -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: scrollwinevent.patch Url: http://rubyforge.org/pipermail/wxruby-users/attachments/20060810/88665de3/attachment-0003.pl -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ScrollWinEvent.i Url: http://rubyforge.org/pipermail/wxruby-users/attachments/20060810/88665de3/attachment-0004.pl -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: scrollwin.rb Url: http://rubyforge.org/pipermail/wxruby-users/attachments/20060810/88665de3/attachment-0005.pl
On Thu, 2006-08-10 at 15:04 +0100, Alex Fenton wrote:> Anyway I adapted your sample to the attached scrollwin.rb, which uses > the Wx::ScrolledWindow class. Then I used it to test adding > ScrollWinEvent to wxruby2. It all seems to work well - though I can''t > figure out how evt_scrollwin_top is supposed to be generated?I added Wx::CLOSE_BOX to the frame constructor so there would be a way to close the app.> People - sorry for adding to the backlog, but would be nice if we could > squeeze this into alpha1. It''s a little patch, seems a fairly core > class, and ScrolledWindow is already in there. Might need to up your > ''fuzz'' settings when appying this patch.No problems applying it. Since I am in a merging mood, I went ahead and took this patch. Thanks (to both Alex and Joe), Kevin