PDA

View Full Version : MessageBox prompt



yopiyop
30 Apr 2008, 4:18 AM
how to get user Input from a MessageBox prompt?



MessageBox.prompt("Titre", " valeur :", new Listener<ComponentEvent>(){
public void handleEvent(ComponentEvent ce) {
Info.display("MessageBox", /*box.getTextBox().getValue()*/"???" );
}
});
thx. David

gslender
30 Apr 2008, 5:11 AM
simple...


final MessageBox box = MessageBox.prompt("Titre", " valeur :", new Listener<ComponentEvent>(){
public void handleEvent(ComponentEvent ce) {
Info.display("MessageBox", box.getTextBox().getValue() );
}
});

yopiyop
30 Apr 2008, 5:32 AM
compiler tell me :

The local variable box may not have been initialized

gslender
30 Apr 2008, 12:56 PM
ok,

So try this...


public void handleEvent(ComponentEvent ce) {
MessageBox box = (MessageBox)ce.component;
....etc
}

yopiyop
1 May 2008, 11:02 PM
sorry, but Cannot cast from Component to MessageBox...

gslender
2 May 2008, 1:48 AM
yep - well I guess the only other option is to assign the MessageBox returned by MessageBox.prompt() to a global and check that when the event fires...

I'd agree that perhaps a better solution should be developed considering the only use case available... odd hey !! :-?