Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Set Keyboard cursor position in Combo
Set Keyboard cursor position in Combo [message #445721] Wed, 10 November 2004 03:45 Go to next message
Kumar is currently offline KumarFriend
Messages: 3
Registered: July 2009
Junior Member
Hi all
In my editable(DROP_DOWN but not READ_ONLY) Combo widget, I have a list
of values. The user can also choose to enter a value. When the user
enters this value, I want to force it to start with "0x". I catch the
Modify Event (ModifyListener) and call setText("0x") on the Combo.

The problem is that the keyboard cursor is located before "0x" rather
than at the end of it, which is what I want. Is there a function I could
call to set the Keyboard Cursor after a certain character or at the end
of the text? I went through SWT API and I could not find a method to do
that. I searched Google but that didn't help.

The only solution I could think of was to simulate a SWT.END KeyEvent
which would put the cursor at the end. I tried writing something but
that code did not work (actually I don't know how that code would look
like). I could post what I have and ask questions about it, if that is
the only solution. Is there any method in the API that I might have
looked over or is the simulated Keyevent the best solution?

Thanks in advance.
Re: Set Keyboard cursor position in Combo [message #445748 is a reply to message #445721] Wed, 10 November 2004 14:52 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
You should be able to call Combo.setSelection(Point) to position the cursor.

"Kumar" <iopener@gmail.com> wrote in message
news:cms2oi$99e$1@eclipse.org...
> Hi all
> In my editable(DROP_DOWN but not READ_ONLY) Combo widget, I have a list
> of values. The user can also choose to enter a value. When the user
> enters this value, I want to force it to start with "0x". I catch the
> Modify Event (ModifyListener) and call setText("0x") on the Combo.
>
> The problem is that the keyboard cursor is located before "0x" rather
> than at the end of it, which is what I want. Is there a function I could
> call to set the Keyboard Cursor after a certain character or at the end
> of the text? I went through SWT API and I could not find a method to do
> that. I searched Google but that didn't help.
>
> The only solution I could think of was to simulate a SWT.END KeyEvent
> which would put the cursor at the end. I tried writing something but
> that code did not work (actually I don't know how that code would look
> like). I could post what I have and ask questions about it, if that is
> the only solution. Is there any method in the API that I might have
> looked over or is the simulated Keyevent the best solution?
>
> Thanks in advance.
>
Previous Topic:Resetting a canvas
Next Topic:Checkbox wrapping in forms
Goto Forum:
  


Current Time: Sat Apr 27 03:12:13 GMT 2024

Powered by FUDForum. Page generated in 0.02964 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top