Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 14:46 Go to next message
Ellen Li is currently offline Ellen LiFriend
Messages: 6
Registered: July 2009
Junior Member
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] Thu, 14 April 2005 01:39 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
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] Thu, 14 April 2005 03:13 Go to previous messageGo to next message
Ellen Li is currently offline Ellen LiFriend
Messages: 6
Registered: July 2009
Junior Member
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 14:36 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
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 22:22 Go to previous message
Ellen Li is currently offline Ellen LiFriend
Messages: 6
Registered: July 2009
Junior Member
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: Sat Apr 20 03:31:47 GMT 2024

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

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

Back to the top