Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » any guidance to create custom textbox that extends SWT textbox
any guidance to create custom textbox that extends SWT textbox [message #911683] Wed, 12 September 2012 05:55 Go to next message
sam mn is currently offline sam mnFriend
Messages: 26
Registered: August 2010
Junior Member
any guidance to create custom textbox that extends SWT textbox?, I need to check/validate entered text into that custom textbox widget for some invalid character.
Can we do this ?
Re: any guidance to create custom textbox that extends SWT textbox [message #913094 is a reply to message #911683] Fri, 14 September 2012 19:06 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
It sounds like you just need to add a Verify listener, no subclassing
required (subclassing SWT classes other than Composite or Canvas is
pretty rare). Example snippet:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet19.java
..

Grant


On 9/12/2012 1:55 AM, sam mn wrote:
> any guidance to create custom textbox that extends SWT textbox?, I need
> to check/validate entered text into that custom textbox widget for some
> invalid character.
> Can we do this ?
Re: any guidance to create custom textbox that extends SWT textbox [message #913240 is a reply to message #913094] Sat, 15 September 2012 03:43 Go to previous messageGo to next message
sam mn is currently offline sam mnFriend
Messages: 26
Registered: August 2010
Junior Member
Thanks for the reply Grant.
However my scenario is like this:
We have a RCP app and there are a lot of places where we have already created text boxes and expecting more textboxes added in future. Now, these textboxes need to validate for certain characters that should not be allowed.

Our idea was to create a custom text widget and let current text boxes be the new custom text widget and future textboxes also use this custom text widget so that our validation added to this custom text widget work.
Re: any guidance to create custom textbox that extends SWT textbox [message #915549 is a reply to message #913240] Mon, 17 September 2012 14:06 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
This does not sound any different, a Verify listener is still the best
way to do this. You can create one and hook it on whichever Texts have
these input constraints. If you want this to happen more seamlessly
(ie.- so that every "new Text(...)" does not need an accompanying
"text.addListener(SWT.Verify...)") then the typical "nice" approach is
to create a Factory class that creates your Texts and adds the Verify
listener.

If you really really want to subclass Text then see
http://www.eclipse.org/swt/faq.php#subclassing .

Grant


On 9/14/2012 11:43 PM, sam mn wrote:
> Thanks for the reply Grant.
> However my scenario is like this:
> We have a RCP app and there are a lot of places where we have already
> created text boxes and expecting more textboxes added in future. Now,
> these textboxes need to validate for certain characters that should not
> be allowed.
> Our idea was to create a custom text widget and let current text boxes
> be the new custom text widget and future textboxes also use this custom
> text widget so that our validation added to this custom text widget work.
Previous Topic:Enabling focus listeners on the composite container
Next Topic:Am I allowed to make SWT jars available in a public maven repository?
Goto Forum:
  


Current Time: Tue Apr 23 12:41:08 GMT 2024

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

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

Back to the top