[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CW_Field Observation



Folks,

One of the things I don't like about CW_FIELD is that if you
want, say, a floating point value in the field, the text
widget looks like it can't be changed by the user. (Windows
machines only, of course.) The reason for this is that, in
fact, the widget *is* set to a non-editable state, even
though all_events are turned on. This allows the code to
secretly examine what you think you are typing and only
allow it if it conforms to what it means to be a floating
value. 

Nice trick, with an unfortunate side-effect, has always
been my view. And it is the reason I've taken great pains
to write several alternatives (of which FSC_FIELD, on my
web page, is the latest).

But this evening I wanted to take advantage of this
unfortunate side effect. I want to turn user input off
and have the appearance of the text widget reflect this fact.
Neat! Except, oops, once the field has been made editable,
it *never* looks uneditable again. :-(

Bummer for me. But it immediately suggests a very simple
fix for CW_FIELD. (I mean, if you don't need or want all
the other nice features I've added to FSC_FIELD while I
was in the process of figuring all this out.) All you
have to do is set the EDITABLE keyword on the text widget
from the get-go. Then set up a NOTIFY_REALIZE on the text
widget. When it is realized (remember it is a compound
widget, so it doesn't know when it is going to be realized),
all you have to do is turn the EDITABLE keyword off.

Now the widget *always* looks editable, like it does in
UNIX. :-)

Cheers,

David

P.S. Let's just say I would have saved myself a lot of
time had I realized this earlier, but I wouldn't have
learned nearly as much.

-- 
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155