Re: Menu Question [message #67280] |
Mon, 13 July 2009 17:42 |
Eric Hudson
Messages: 19 Registered: June 2006
|
Junior Member |
|
|
On Jul 13, 8:56 am, David Fanning <n...@dfanning.com> wrote:
>
>> On a probably completely unrelated item, is there a way to
>> programmatically move the cursor around a draw window?
>
> You could try TVCRS.
>
Thanks again for your help David.
I'll give up on menus, but want to follow up on the cursor. I forgot
to mention that I'm using object graphics, so I guess TVCRS won't
work. Just to be more clear about my goal (in case there is another
way I'm not thinking of), I have a label under my window (sort of like
IMGWIN) that I currently update on mouse motion events in my draw
window. I also capture keyboard events, and depending on the arrow
key pressed can generate a fake mouse motion event (I just add an
offset to the event.x,y). This updates the label fine, but the cursor
doesn't move so my next keyboard event is at the same location.
I guess I could just shut off the cursor when it enters my draw window
(SetCurrentCursor to some invisible cursor) and then make my own
cursor as an overlay and move it around. But this seems like a huge
pain for something as conceptually simple as programmatically nudging
the real cursor. Also, is there any way to figure out what the cursor
is doing (or make it do something) outside of a draw window? For
example, if I wanted to push it from one draw window to another? Then
my kludge above wouldn't seem to work.
Thanks,
Eric
|
|
|
Re: Menu Question [message #67283 is a reply to message #67280] |
Mon, 13 July 2009 16:33  |
Eric Hudson
Messages: 19 Registered: June 2006
|
Junior Member |
|
|
On Jul 13, 8:56 am, David Fanning <n...@dfanning.com> wrote:
>
>> On a probably completely unrelated item, is there a way to
>> programmatically move the cursor around a draw window?
>
> You could try TVCRS.
>
Thanks again for your help David.
I'll give up on menus, but want to follow up on the cursor. I forgot
to mention that I'm using object graphics, so I guess TVCRS won't
work. Just to be more clear about my goal (in case there is another
way I'm not thinking of), I have a label under my window (sort of like
IMGWIN) that I currently update on mouse motion events in my draw
window. I also capture keyboard events, and depending on the arrow
key pressed can generate a fake mouse motion event (I just add an
offset to the event.x,y). This updates the label fine, but the cursor
doesn't move so my next keyboard event is at the same location.
I guess I could just shut off the cursor when it enters my draw window
(SetCurrentCursor to some invisible cursor) and then make my own
cursor as an overlay and move it around. But this seems like a huge
pain for something as conceptually simple as programmatically nudging
the real cursor. Also, is there any way to figure out what the cursor
is doing (or make it do something) outside of a draw window? For
example, if I wanted to push it from one draw window to another? Then
my kludge above wouldn't seem to work.
Thanks,
Eric
|
|
|
Re: Menu Question [message #67295 is a reply to message #67283] |
Mon, 13 July 2009 05:56  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Eric Hudson writes:
> I'm not sure what you mean by 'call your button event handler directly
> from the draw widget event handler with an obviously fake "button"
> event' ... communication between these two handlers isn't an issue,
> instead I just don't know how to "push" the button and make it drop
> down its submenu.
Yes, I wasn't thinking clearly yesterday. Buttons in menu bars,
or with the MENU keyword set, do not generate events that we
have access to. Nor can we trip them, except with the mouse,
for some reason. I don't know why this is.
> On a probably completely unrelated item, is there a way to
> programmatically move the cursor around a draw window?
You could try TVCRS.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: Menu Question [message #67296 is a reply to message #67295] |
Sun, 12 July 2009 23:13  |
Eric Hudson
Messages: 19 Registered: June 2006
|
Junior Member |
|
|
Thanks for the rapid response.
>
>> So then I thought I'd be clever and have a single top level button
>> which I then programmatically 'push' in order to automatically drop
>> down the menu. That is, I capture the right click on the draw window
>> which says "time for a menu" then I show the top level base of my
>> menu, with one button in it, and then tell the button to 'drop down
>> your menu' without forcing the user to make the extra mouse click.
>> But I can't figure out how to programmatically push the button -- send
>> event doesn't seem to do it.
>
> Did you try to use SEND_EVENT to put the event on the event queue?
> What if you just called your button event handler directly from
> your draw widget event handler, with an obviously fake "button"
> event?
>
SEND_EVENT seems to just pass the event along to the XMANAGER event
handler for my menu, rather than opening up the pulldown menu. That
is, it yields different results than physically clicking on the
button. Maybe I'm sending the wrong event structure? Since I never
see the menubutton push events (the ones that open submenus) I don't
know what they look like. Interestingly (maybe) the event that I get
in my menu handler is not the same as the one that I am sending to the
button to try to "push it" -- the "handler" element is changed from my
button ID to my base ID.
I'm not sure what you mean by 'call your button event handler directly
from the draw widget event handler with an obviously fake "button"
event' ... communication between these two handlers isn't an issue,
instead I just don't know how to "push" the button and make it drop
down its submenu.
On a probably completely unrelated item, is there a way to
programmatically move the cursor around a draw window? I'd like to
make arrow key presses move the cursor in a draw window (to more
accurately move), and although I don't have a problem turning the
keypresses into mouse motion events, I can't seem to actually move the
cursor. Put the answers to these two questions together and you have
a way of making demos for people, by programmatically moving the
cursor up to menu items and then "pushing" them, to show the user what
to do.
Thanks again,
Eric
|
|
|
Re: Menu Question [message #67299 is a reply to message #67296] |
Sun, 12 July 2009 16:51  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Eric Hudson writes:
> I am having issues with menus and am hoping someone has a suggestion.
> Basically, I want a context menu look and functionality, with the
> ability to have accelerators (any idea why accelerators are forbidden
> for context menus?)
I think this is one of the 3 or 4 "Mysteries of the Universe",
if I'm not mistaken.
> I've tried just making a button group where each button spawns a
> pulldown menu (like what you get with CW_PDMENU) but it seems that the
> top level buttons can't have accelerators (while any button in the
> pulldown menus can).
>
> So then I thought I'd be clever and have a single top level button
> which I then programmatically 'push' in order to automatically drop
> down the menu. That is, I capture the right click on the draw window
> which says "time for a menu" then I show the top level base of my
> menu, with one button in it, and then tell the button to 'drop down
> your menu' without forcing the user to make the extra mouse click.
> But I can't figure out how to programmatically push the button -- send
> event doesn't seem to do it.
Did you try to use SEND_EVENT to put the event on the event queue?
What if you just called your button event handler directly from
your draw widget event handler, with an obviously fake "button"
event?
> On a related note, I wrote an extension to CW_PDMENU which allows the
> setting of accelerators and checked_menus for each menu item (rather
> than having the string 'code / menuitem name / handler' I just
> appended ' / accelerator / checked?' It works fine (except not for
> context menus and not for the top level buttons), but this seems like
> such an obvious thing to do I was wondering if it had been implemented
> elsewhere and I just missed it.
The best ideas are always the obvious ones. :-)
Cheers,
David
P.S. Context menus are pretty weird. I've never been able to
make them really sing and dance exactly the way I wanted them
to. :-)
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|