Hey Alex, Found a solution to the problem that was occuring with wxMSW and the Wx::TextCtrl, have yet to verify that this will work in linux, but my little trick to the matter, was simple, thanks to the things that are provided with both Wx::TextCtrl, and Wx::Window classes. I''m providing this bit of information for thoes who may have trouble with dealing with Wx::TextCtrl, _AND_ have word wrapping action going on. As this seems to be a problem with dealing with word wrapping, I''ve been able to create a solution to make autoscrolling work. I create my own method for appending text to the Wx::TextCtrl buffer, Named append_buffer. Here is what it looks like: class MyBuffer < Wx::TextCtrl def append_buffer(text) # I have some processing of the text to colorize it, but I think this is just generally a problem # with word wrapping in general self.freeze # Freeze the buffer, so the control doesn''t try to scroll on us, don''t need that. Plus makes for faster updates succ,c,sl = self.position_to_xy(self.get_last_position) # Need to know where we are at in the buffer. Only part used is sl # Here is where I process my text, but shouldn''t be needed for other stuff, least your doing an Extended Text Formatting self.append_text(text) self.thaw # Okay, we are done adding, so you can clear out now succ,c,se = self.position_to_xy(self.get_last_position) # Now we need to know where the buffer is, since we added data. self.scroll_lines((el-sl)+2) # Move the window to the last line given. Add 2 more fake lines, to ensure we get to the absolute bottom end end And that''s all there is to it. Just happy to finally figure this out, cause it was bugging the heck out of me. I''ll write back here in a few, once I test the changes on Linux, and ensure it works there as well, without any problems. Mario Steele _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
Following up, Confirmed, that this patch also works perfectly fine on wxGTK as well. One of the major obstacles out of my way, finally. Was about to tear my hair out from trying to figure out ways to get around this. Even went as far as to write a control to handle the displaying of the text, but I wanted to avoid that, if I could use Wx::TextCtrl. Just to psyched about not having to write a work around on it. L8ers, Mario Steele On 6/17/07, Mario Steele <mario at ruby-im.net> wrote:> > Hey Alex, > > Found a solution to the problem that was occuring with wxMSW and the > Wx::TextCtrl, have yet to verify that this will work in linux, but my little > trick to the matter, was simple, thanks to the things that are provided with > both Wx::TextCtrl, and Wx::Window classes. > > I''m providing this bit of information for thoes who may have trouble with > dealing with Wx::TextCtrl, _AND_ have word wrapping action going on. As > this seems to be a problem with dealing with word wrapping, I''ve been able > to create a solution to make autoscrolling work. > > I create my own method for appending text to the Wx::TextCtrl buffer, > Named append_buffer. > > Here is what it looks like: > > class MyBuffer < Wx::TextCtrl > def append_buffer(text) > # I have some processing of the text to colorize it, but I think this > is just generally a problem > # with word wrapping in general > self.freeze # Freeze the buffer, so the control doesn''t try to scroll > on us, don''t need that. Plus makes for faster updates > succ,c,sl = self.position_to_xy(self.get_last_position ) # Need to > know where we are at in the buffer. Only part used is sl > # Here is where I process my text, but shouldn''t be needed for other > stuff, least your doing an Extended Text Formatting > self.append_text (text) > self.thaw # Okay, we are done adding, so you can clear out now > succ,c,se = self.position_to_xy(self.get_last_position) # Now we need > to know where the buffer is, since we added data. > self.scroll_lines ((el-sl)+2) # Move the window to the last line > given. Add 2 more fake lines, to ensure we get to the absolute bottom > end > end > > And that''s all there is to it. Just happy to finally figure this out, > cause it was bugging the heck out of me. I''ll write back here in a few, > once I test the changes on Linux, and ensure it works there as well, without > any problems. > > > Mario Steele >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20070617/3e84df8c/attachment.html
Hi Mario Firstly, very sorry for the delay in replying. I''ve been abroad, on holiday and off line for a little while. Mario Steele wrote:> Found a solution to the problem that was occuring with wxMSW and the > Wx::TextCtrl, have yet to verify that this will work in linux, but my > little trick to the matter, was simple, thanks to the things that are > provided with both Wx::TextCtrl, and Wx::Window classes.Thanks for sharing that method. Once I read your email and re-read the bug I realised it was same as/similar to something I worked around for Weft QDA, using freeze/remember position/thaw. Since we''ve both hit the same problem and solution I''m inclined to add this to wxSugar for the next release. alex
Possibly Parallel Threads
- Major Breakthrough?
- [ wxruby-Bugs-11446 ] Wx::TextCtrl behaves wrong when scrolling
- problem with TextCtrl#get_insertion_point
- [ wxruby-Bugs-15025 ] TextCtrl method get_insertion_point() return is constrained to a 16 bit number
- wxruby2-preview Gauge and wx-sugar with SplitterWindow