[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: Bug in Text.setSelection?
|
All of the setSelection() methods in SWT, in addition to setting the
selection, scroll or do whatever work is necessary to bring the selection to
the attention of the user. So, to get what you want would requre new API.
However, I believe that (due to a bug in Windows), the EM_SCROLLCARET is not
necessary and that the text control will scroll anyways. Try commenting the
line out and see if it doesn't scroll.
"Doug Pearson" <doug-list@xxxxxxxxxxxxxx> wrote in message
news:d9d85q$120$1@xxxxxxxxxxxxxxxxxxx
> The code for the Text widget's set selection on Windows looks like this:
>
> public void setSelection (int start) {
> checkWidget ();
> if (OS.IsDBLocale) start = wcsToMbcsPos (start);
> OS.SendMessage (handle, OS.EM_SETSEL, start, start);
> OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
> }
>
> I'm looking to implement a common pattern with a text widget, where if
> the user has set the caret to a position other than the end of the
> widget the window doesn't scroll as new text is added.
>
> The underlying control supports this but because of the call to
> "EM_SCROLLCARET" in this method I don't think it's possible to implement
> this in SWT. (You need to move the selection to add text to the end of
> the control and then move it back).
>
> This scroll caret call seems clearly unnecessary as there's a separate
> showSelection() method:
>
> public void showSelection () {
> checkWidget ();
> OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
> }
>
> so if you want the scroll behavior you can call this method.
>
> So my question is simple: is there any reason not to treat this as a bug
> or shall I go ahead and write it up?
>
> Thanks,
>
> Doug
>