Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Is IP address input widget available
Is IP address input widget available [message #453827] Mon, 11 April 2005 10:46 Go to next message
Eclipse UserFriend
I have a ip address input field (Text). Is there any way to make it 4
segments ( . . . ), and only valid input allowed ( eg 0-255 for
each segment)?

Any information would be appreciated!

Ellen
Re: Is IP address input widget available [message #453926 is a reply to message #453827] Wed, 13 April 2005 21:39 Go to previous messageGo to next message
Eclipse UserFriend
The only way I can think of is to use the text widget in the swt.custom
package and do some creative paint listening. I can't think of any way
to do it natively.

Daniel

Ellen Li wrote:

> I have a ip address input field (Text). Is there any way to make it 4
> segments ( . . . ), and only valid input allowed ( eg 0-255
> for each segment)?
>
> Any information would be appreciated!
>
> Ellen
>
Re: Is IP address input widget available [message #453927 is a reply to message #453926] Wed, 13 April 2005 23:13 Go to previous messageGo to next message
Eclipse UserFriend
Thanks!
I created a IPText widget extends Composite, which has 7 Text widgts as
children of “this”. It seems work fine.
public IPText ( Composite parent, int style) {
super(parent, style);
final FormLayout formLayout = new FormLayout();
this.setLayout(formLayout);

init();
createTextBoxes(); // create text boxes

}

I tried to register a listener public void addModifyListener
(ModifyListener listener) {
checkWidget ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Modify, typedListener);
}

But this listener does not catch modify event from its children, Text. Is
there any way I can propagate event to its parent? Such as :
public void addModifyListener (ModifyListener listener) {
checkWidget ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Modify, typedListener);

//text is one of the children
text. addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
// send ModifyEvent to text’s parent, IPText.
}
});
}


Thanks so much!!
Ellen
Re: Is IP address input widget available [message #453943 is a reply to message #453927] Thu, 14 April 2005 10:36 Go to previous messageGo to next message
Eclipse UserFriend
You will need to hook the event on each widget. This event (and most
others) are not propagated.

"Ellen Li" <eli@stonewallnetworks.com> wrote in message
news:cceb8a941038b0fa551491066e3b3bc9$1@www.eclipse.org...
> Thanks!
> I created a IPText widget extends Composite, which has 7 Text widgts as
> children of
Re: Is IP address input widget available [message #453959 is a reply to message #453943] Thu, 14 April 2005 18:22 Go to previous message
Eclipse UserFriend
Thanks. I made it work.

public void addModifyListener (ModifyListener listener) {
// redirect text box event to caller
for (int i = 0; i < ipSegments.size(); i++) {
if ( (i % 2) == 0 ) {
Text t = (Text)ipSegments.elementAt(i);
t.addModifyListener(listener);
}
}
}
Previous Topic:TableViewer: radiobutton behaviour
Next Topic:keyboard shortcuts for cut/copy/paste failing
Goto Forum:
  


Current Time: Sun Jul 13 01:00:12 EDT 2025

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

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

Back to the top