widget text [message #37766] |
Tue, 20 January 2004 08:12  |
Nuno Oliveira
Messages: 75 Registered: October 2003
|
Member |
|
|
Hi.
I'm working with text widget with keyword editable and I would like that the
user would not be able to insert more than three characters. Keyword xsize
only controls the size, not the length of the contents.
The only that occurs to me is seeking for all widget text events, and if the
string has per example four characters then it extracts a sub string with
the first three characters.
The question if there's a parameter or any other way to do this easier.
Cheers,
Nuno.
|
|
|
|
Re: Widget text [message #43181 is a reply to message #37766] |
Fri, 18 March 2005 00:02  |
Antonio Santiago
Messages: 201 Registered: February 2004
|
Senior Member |
|
|
CSUIDL PROGRAMMEr wrote:
> HI i am learning Widget IDL programming
> I want to know, how to process text fro Widget _ text such that when
> user enters text and presses submit button action is taken. How to pass
> text to button event handler
>
The best thing you can do is saw a simple example IDL code or a library
utility.
When your widget is relatively simple, normaly assigns an structure with
all needed information to the UVALUE of the main widget_base.
info = { text: your_widget_text, button: your_widget_button}
WIDGET_CONTROL, base, SET_UVALUE=info
Also you need to "call" your widget_text and widget_button assing an
string into their UVALU:
WIDGET_CONMTRL, you_text, SE_UVALUE='TEXT'
WIDGET_CONTROL, your_button, SET_UVALUY='BUTTON'
Also, you register an event_handler to handle all the events on the main
widget_base. Get the event.id, get its UVALUE (and get the UVALUE from
event.top, that is the main widget):
PRO event_handler, event
WIDGET_CONTROL, event.id, GET_UVALUE=uval
WIDGET_CONTROL, event.top, GET_UVALUE=info
CASE uval OF
'TEXT': print, 'event on widget_text'
'BUTTON': BEGIN
print, ' event on button'
WIDGET_CONTROL, info.text, GET_VALUE=string
print, 'your text is' + string
END
END
More or less these are the steps.
Another method is to asign to button's UVALUE the widget_text. Creates
the button with EVENT_PROC:
button = WIDGET_BUTTON(VALUE='ok', UVALUE=your_widget_text,
EVENT_PROC=my_proc)
PRO my_proc, event
WIDGET_CONTROL, event.id, GET_UVALUE=text
WIDGET_CONTROL, text, GET_VALUE=string
print, string
END
Bye,
Antonio.
|
|
|