Re: CW_FIELD question [message #54233 is a reply to message #54231] |
Fri, 25 May 2007 11:19  |
cmancone
Messages: 30 Registered: May 2007
|
Member |
|
|
On May 25, 2:01 pm, mark...@gmail.com wrote:
> I know there must be something basically wrong with my thinking on
> this, but I can't figure out why this doesn't work. I'm writing a
> program that makes use of DRAW and TEXT widgets without an event
> handling routine. I would like some widgets to be used as numeric
> entry fields in which the user can enter numeric data to be read by
> the program. These should not be modal widgets.
> Here is an example of what I'm trying to do:
>
> PRO Example
>
> tlb = Widget_Base(Column=1)
>
> field1 = WIDGET_TEXT(tlb, /EDITABLE)
>
> field2 = CW_FIELD(tlb, /FLOATING)
>
> WIDGET_CONTROL, tlb, /REALIZE
> XManager, 'example', tlb, /No_block
>
> quita = 0
>
> curval=''
>
> WIDGET_CONTROL, field1, GET_VALUE=curval
>
> while quita ne 1 do begin
>
> WIDGET_CONTROL, field1, GET_VALUE=f1val
> WIDGET_CONTROL, field2, GET_VALUE=f2val
>
> if f1val ne curval then begin
> curval = f1val
> print, curval
> print, f2val
> if curval eq 'q' then quita = 1
> endif
> wait, 0.1
>
> endwhile
>
> WIDGET_CONTROL, tlb, /DESTROY
>
> END
>
> When you run this program, the WIDGET_TEXT field is editable and
> behaves as expected, but the CW_FIELD field is not editable. What is
> going on? There must be something basic that I'm missing here.
>
> Thanks,
> Mark
Why don't you want to use an event manager? That would be my first
question. If you re-write it without that last part, it works fine:
PRO Example
tlb = Widget_Base(Column=1)
field1 = WIDGET_TEXT(tlb, /EDITABLE)
field2 = CW_FIELD(tlb, /FLOATING)
WIDGET_CONTROL, tlb, /REALIZE
XManager, 'example', tlb, /No_block
quita = 0
curval=''
WIDGET_CONTROL, field1, GET_VALUE=curval
END
I'm not an expert on this (I'm very new to widgets myself) but it
seems like you have to do this properly. Apparently, as long as you
are in the while loop and are using the wait, the cw_field doesn't
work. I can hazard a guess why that is. I have a suspicion that
cw_field isn't just a regular input box. It actually has some pre-
processing before it allows anything to populate it's field - that's
how it forces you to only input numeric values in the text box. I'm
guessing that somehow the "infinite" while/wait loop you have going
prevents it from executing this functionality and actually putting
text into the input box. If so, I'm guessing you're simply stuck, and
have to do it another way.
|
|
|