widget_text editable and all_events [message #65837] |
Wed, 25 March 2009 11:10 |
Vince Hradil
Messages: 574 Registered: December 1999
|
Senior Member |
|
|
It's always bugged me the way widget_text handles events. Namely, I
have two choices:
1- set editable and unset all_events: then I have to deliver a CR to
get the value to "take".
2- set editable and set all_events: then the event handler fires every
time something is typed.
What I'd really like is something in between. The reason being that I
like to validate the input to make sure it's a number before I accept
it. Then if it is jibberish, I put the old value back, something like
this:
'GOODENOUGH': begin
holdge = (*info).data.goodenough
widget_control, (*info).widgets.goodenough_text, get_value=val
if is_number(val) gt 0 then begin
if long(val) ne holdge then begin
(*info).data.goodenough = long(val)
widget_control, (*info).widgets.goodenough_text,
set_value=strtrim(long(val),2)
endif
endif else begin
widget_control, (*info).widgets.goodenough_text,
set_value=strtrim(holdge,2)
endelse
end
Well, scenario 2- makes it so that you cannot just backspace out the
whole thing then start typing. What I would like is for the
validation to occur if either (1) the user hits CR or (2) the text box
loses focus (aha!)
Thanks for your ideas.
Vince
|
|
|