Re: Strange widget question / IDL [message #13959] |
Mon, 21 December 1998 00:00 |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Dyer Lytle wrote:
> Hi all,
>
> I am trying to use pull-down menus in a way for which they
> were never intended and am failing miserably. I have a draw
> widget containing text areas and I want the user to easily change
> the text in any particular area by clicking on that area and having
> a menu of possible values pop up any one of which could be selected
> by moving the mouse to it and releasing the mouse button.
>
> The way I tried to do this was to use a bulletin-board base with
> pull-down
> menu buttons hiding under the draw widget. Then when the user
> clicks on the draw widget, I catch the event, decide which pull-down
> menu I need and send an event to the appropriate button. I haven't
> been able to activate the menu this way. How do I tell a button to
> push itself? Any one have an alternative way to do this?
>
> I know I can just pop up a new widget with a list and have the user
> click on
> the value but I was hoping to make the user-interface as simple
> as possible.
>
> Thanks,
>
> -Dyer Lytle in Tucson
Dear Dyer,
May be this is a solution or an idea to solve the problem:
PRO test_menu
base=WIDGET_BASE(row=2)
id_quit=WIDGET_BUTTON(base,value='QUIT',uvalue='QUIT')
id_pull_down= CW_PDMENU(base, [ '1\Switch', '0\ * on' , '2\ off'
],uvalue='MENU', /RETURN_FULL_NAME,ids=ids)
WIDGET_CONTROL,base,/realize
id=-1
WHILE id NE id_quit DO BEGIN
test=WIDGET_EVENT(base)
WIDGET_CONTROL,test.id,get_uvalue=uvalue
CASE uvalue OF
'QUIT': BEGIN
WIDGET_CONTROL,base,/destroy
RETURN
END
'MENU': $
BEGIN
CASE STRCOMPRESS(test.value,/remove_all) OF
'Switch.off' : BEGIN
WIDGET_CONTROL,ids[1],set_value= ' on'
WIDGET_CONTROL,ids[2],set_value= '* off'
END
'Switch.*on' : BEGIN
WIDGET_CONTROL,ids[1],set_value= '* on'
WIDGET_CONTROL,ids[2],set_value= ' off '
END
ELSE:
ENDCASE
END
ELSE:
ENDCASE
ENDWHILE
END
R.Bauer
|
|
|