textbox value on destroy? [message #28622] |
Thu, 03 January 2002 02:51  |
Gert Van de Wouwer
Messages: 21 Registered: January 2002
|
Junior Member |
|
|
Hi,
I need to store the value of a textbox in a file. The problem is how to do
this when the user 1) modifies the textbox and then 2) closes the
application. It seems that the textbox's 'value' is already gone when a
kill_notify event is generated.Any ideas how to handle this?
Gert
|
|
|
Re: textbox value on destroy? [message #28705 is a reply to message #28622] |
Fri, 04 January 2002 08:39  |
Pavel A. Romashkin
Messages: 531 Registered: November 2000
|
Senior Member |
|
|
Gert Van de Wouwer wrote:
>
> yep, thats the obvious thing. Unfortunately, I cannot figure out WHEN to do
> this in the case that the user closes the apllication.
I can't believe nobody answered you. I am sorry.
May the following example be of any help?
; *** Begin code ****
pro test_event, ev
widget_control, widget_info(ev.top,/child), get_value=text
print, text
if tag_names(ev, /structure_name) eq $
"WIDGET_KILL_REQUEST" then $
widget_control, ev.top, /destroy
end
pro test
base = widget_base(/tlb_kill_request)
text = widget_text(base, /editable)
widget_control, base, /realize
xmanager, 'test', base, /no_block
end
;*** End code ***
You can see that the value entered into the textbox is printed any time
an event occurs (like, when you press "Enter"), and also when you kill
the widget by clicking on the system-specific window kill control.
Pavel
|
|
|
Re: textbox value on destroy? [message #28706 is a reply to message #28622] |
Fri, 04 January 2002 08:32  |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
Gert Van de Wouwer wrote:
>
> yep, thats the obvious thing. Unfortunately, I cannot figure out WHEN to do
> this in the case that the user closes the apllication.
You can always make the value of the text box a returned keyword value. You
will need to set up an event handler that will store the value of the text
field somewhere in the top level base's uValue as a pointer. Anytime the user
modifies the text object, the event handler will store its value in the TLB's
uvalue. After the widget portion of the application is destroyed, the pointer
reference still exists and the value it points to can be retrieved.
I'm a bit rusty with this stuff and you will probably find a much better
example on David's webpage.
PRO MyApp, TheText = TheText
If n_elements(TheText) EQ 0 Then TheText = ''
TxtPtr = Ptr_new(TheText)
tlb = widget_base(.....)
build gui here
Info = {TxtPtr:TxtPtr, other things here too}
Widget_Control, tlb, set_Uvalue = info, /no_copy
XMANAGER, .....
TheText = *TxtPtr ;<----- get the value from the pointer
Ptr_Free, TxtPtr ;<---- free the pointer
Return
END
Later....
I just looked at http://www.dfanning.com/programs/textbox.pro and this is
indeed a much better example.
Ben
--
Ben Tupper
Bigelow Laboratory for Ocean Science
180 McKown Point Road
West Boothbay Harbor, ME 04575
www.bigelow.org
btupper@bigelow.org
|
|
|
Re: textbox value on destroy? [message #28707 is a reply to message #28622] |
Fri, 04 January 2002 07:38  |
Gert Van de Wouwer
Messages: 21 Registered: January 2002
|
Junior Member |
|
|
"Ben Tupper" <pemaquidriver@tidewater.net> wrote in message
news:3C35155B.F28DFDAE@tidewater.net...
> Hi,
>
> I have suspicion that I am making your problem out to be too simple, so
this
> mightt not work for you... but what the heck.
>
> You can always retrieve that value of a text widget (text box?) if you
have
> the Widget identifier.
>
> Widget_Control, TextID, Get_Value = TheText
>
>
>
> Ben
>
yep, thats the obvious thing. Unfortunately, I cannot figure out WHEN to do
this in the case that the user closes the apllication.
|
|
|
Re: textbox value on destroy? [message #28710 is a reply to message #28622] |
Thu, 03 January 2002 18:37  |
Ben Tupper
Messages: 186 Registered: August 1999
|
Senior Member |
|
|
Hi,
I have suspicion that I am making your problem out to be too simple, so this
mightt not work for you... but what the heck.
You can always retrieve that value of a text widget (text box?) if you have
the Widget identifier.
Widget_Control, TextID, Get_Value = TheText
Ben
Gert Van de Wouwer wrote:
> Hi,
>
> I need to store the value of a textbox in a file. The problem is how to do
> this when the user 1) modifies the textbox and then 2) closes the
> application. It seems that the textbox's 'value' is already gone when a
> kill_notify event is generated.Any ideas how to handle this?
>
> Gert
--
Ben Tupper
248 Lower Round Pond Road
POB 106
Bristol, ME 04539
Tel: (207) 563-1048
Email: PemaquidRiver@tidewater.net
|
|
|