Thilko Richter
2008-Sep-11 12:46 UTC
[fxruby-users] TEXT_AUTOSCROLL in FXText with usage of FXDataTarget
Hello, I have a FXTextfield connected with a FXDataTarget. My FxTextField is a logging window, so I always would like to see the last line visible. I initialized the FXText with FXText::TEXT_AUTOSCROLL, but, I dont know why, the last line is no keep visible, although I can see the updates of the TextField through the FXDataTarget. Currently I switch to a manually assignment of the text and call "makePositionVisible", but is this the right solution? As far as I understand the TEXT_AUTOSCROLL should always scroll to the end? Thx, Thilko
Jeroen van der Zijp
2008-Sep-11 13:44 UTC
[fxruby-users] TEXT_AUTOSCROLL in FXText with usage of FXDataTarget
On Thursday 11 September 2008, Thilko Richter wrote:> Hello, > > I have a FXTextfield connected with a FXDataTarget. My FxTextField is > a logging window, so I always would like to see the last line > visible. I initialized the FXText with FXText::TEXT_AUTOSCROLL, but, I > dont know why, the last line is no keep visible, although I can see > the updates of the TextField through the FXDataTarget. Currently I > switch to a manually assignment of the text and call > "makePositionVisible", but is this the right solution? > > As far as I understand the TEXT_AUTOSCROLL should always scroll to the end?Actually, TEXT_AUTOSCROLL isn''t implemented ;-) Its not common to connect FXText via FXDataTarget, on account of the amount of data that may be transferred, and the huge cost of updating text metrics non- incrementally. My suggestion is to append text piecemeal fashion: text->appendText(string); text->makePositionVisible(text->getLength()); This will incrementally update and scroll to the last character position. If you''re adding a LOT of text, you may want to: excess=text->getNumRows()-maximum_number_of_rows; if(0<excess) text->removeText(0,text->countRows(0,excess)); Which will trim from the top of the widget, to keep the number of lines less than maximum_number_of_rows. Hope this helps, - Jeroen