How can I make the Excel cell menu update when the keyboard's context menu key is pressed - excel

At the moment, I have code that runs in the Application's SheetBeforeRightClick event, but I've found that this code doesn't run when I press the keyboard's Context Menu key instead of using the right mouse button, which means that I get the wrong menu.
I could use the SheetSelectionChange event instead, but I'd imagine this would be quite error prone. Is there a more elegant way of doing it?

There is a BeforeContextMenu event you can use.
http://msdn.microsoft.com/en-us/library/aa193082(office.11).aspx
It should catch both the right click and the keyboard key.

Related

Move command in Dialog based aplications

I working on Dialog based applications once i right click on the Dialog Title bar a drop down list is coming with two options 1. Move and 2. Alt+F4 close. Once the User Press Move and he can able to drag the window as he desired and I add the On NC Hits Test to stop dragging its stopping normal dragging but it is not working in this particular context can any body help me in fixing this Bug.
When the user use the keyboard interface, he can move a windows with the arrow keys, without using the mouse.
If you want to limit the position of your dialog, process the WM_MOVING message.

How to generate a key press event in traitsui (Mayavi)?

I have a Mayavi scene widget with a toolbar and I want to add a button with the same behaviour that pressing CTRL+C, CTRL+A (Change between camera and actor interactor mode).
I think that simulating a key press event by cliking in the button is the simplest aproach to do that, so the question is ¿How to simulate a key press event in Traitsui (the Mayavi GUI toolkit)?
Does anybody know another way to perform the same action that CTRL+C, CTRL+A?
Thanks in advance!
There is no straightforward way to simulate a keypress event in a mayavi scene or that I am aware of in traitsui or enaml.
This is also an extremely non-traithonic way of getting the desired behavior. The right way to do it is to make calls to the tvtk interactor, asking it for the right style:
self.scene.interactor.interactor_style.set_current_style_to_trackball_camera()
self.scene.interactor.interactor_style.set_current_style_to_trackball_actor()

WinRT XAML - how to fix higlight issues?

When I'm testing my app on a mouse-driven device, I'm seeing a couple of odd highlight issues that I would like to try and resolve.
The first occurs when I call up the app bar, hover the mouse over a button (at which point the button goes grey) and then press Escape to dismiss the app bar. If I then call up the app bar again, the button has stayed grey, even if the mouse isn't over it, and remains in that state until I move the mouse over it and then away again.
I can't immediately see a property of the button that I can reset to clear that state when the app bar gets dismissed.
The other oddity I'm seeing is that sometimes the first item in the list on the page will get a box drawn around it:
This seems to happen when the app bar is being dismissed. I'm guessing that this is because the item is in a particular state that causes the box to appear but I'm not sure what state or how to clear it. The box does not appear during normal use of my app.
Thanks for any clarification or solutions you can provide.
I found a simple way to workaround this issue. In the code for Clicked/Tapped set Visibility of the button:
CreateNewDatabase.Visibility = Visibility.Collapsed;
CreateNewDatabase.Visibility = Visibility.Visible;
It will reset button state to Normal.
Hope this helps!
So, the issue is that the VisualState for the Button is being set to PointedOver, and then not being unset (because your mouse isn't leaving the bounds of the control and therefore triggering a PointerExited event). What this means is that you'll have to manually set the VisualState of the Button if you want it to change in this manner. You could do it on AppBar's Closed event. Basically, do a recursive check of all Children of the Content property of the AppBar using the VisualTreeHelper. Check to see if the Child is a Button. If it is, set its VisualState using VisualStateManager.GoToState().
I've also figured out what was causing the black box around the button - it is to indicate that the button has Focus.
The rather strange thing is that I'm not really sure why that specific button is getting focus or how a user is supposed to give focus to a button without it just randomly happening so, until I figure that out, I've decided to comment out the Focus state support from the Visual Manager XAML used in the default GridView item style.

LiveCode: how to dismiss a popup button

If I instantiate a popup button, I can dismiss it by selecting one of the options or by clicking somewhere else. Is there a good way to dismiss it from a script? I tried setting the menuHistory, but it doesn't seem to have any effect.
Mark - if you check the openStacks is the first line empty while the popup menu is displayed? I think it is and then you could test that way.
Answering my own question:
I haven't found a good way to determine whether a popup menu button is displayed yet - none of the usual property checks seem to work. But I sidestepped the issue thusly:
in my scrollwheel handler I
dispatch "menuPick" to button "PluginMenu"
Then in the menuPick handler of the PluginMenu button I have
if pItemName is empty then
lock screen
put word 2 of the selectedline of field "xyzzy" into tLine
select after line tLine of field "xyzzy"
click at the selectedloc
unlock screen
end if
where pItemName is the normal menuPick parameter.
If I could determine when the popup was visible I could limit the menuPick call to just the times when it's on screen, but otherwise the effect is just to click at the end of the line, deselecting the popup if it's on top.
Edit: the scrollwheel handler mentioned above is in the rawKeyUp handler of field "xyzzy".
Edit 2: as mentioned, that should be "rawKeyDown" instead of "rawKeyUp".
And as Trevor mentioned, checking line 1 of the openStacks makes it even better:
if line 1 of the openStacks is empty then
dispatch "menuPick" to button "PluginMenu"
end if
It may be that you need to fake your popup menu with a palette stack which closes on suspendStack. That way there's no blocking involved and you can close it whenever you like. You would need to mess with the focus of the field I think after opening the palette so it still has the focus.
I just tried clicking a button containing the following script then clicking on a popup button.
on mouseUp
set the uActive of me to not the uActive of me
if the uActive of me then send "test" to me in 2000 millisecs
end mouseUp
on test
put the millisecs
if the uActive of me then send "test" to me in 2000 millisecs
end test
The popup seems to be modal and blocks the timed routine in the button script. I'm thinking that Monte's idea of faking the popup might be a good one ;)
You can't access already open menus by script. However, on Windows, if you open the popup menu with the popup command in a mouseDown handler, the mouseDown handler will run till the end instantly. If you use a stack panel instead of a regular popup menu, you might be able to close the stack panel by script (I haven't tried this). I don't think that this is possible on Mac OS X because menus block any currently running scripts until the menu closes.

Altering the YUI menu's mousing behavior

I'm using Yui to build a "popup" menu that works a bit differently with the mouse than usual. This is not a ContextMenu, because I want it to respond to left clicks, and the ContextMenu seems bent on responding to right clicks.
Following the examples, if I do this, the menu comes up and everything is close to how I want it:
YAHOO.util.Event.addListener(myClickTarget, 'click', myThingGotClicked);
In my myThingGotClicked function, I manually set the menu's position and show() it.
My problem is that I want to "bind" the menu visibility to the state of the mouse button. That is, on a mouseDown, I want the menu to come up, and on a mouseUp, I want the menu to disappear (selecting the active item, if any). So, listening to the 'click' event doesn't do the right thing, because a "click" is only sent after mouseUp.
The "obvious" solution is to do this:
YAHOO.util.Event.addListener(myClickTarget, 'mousedown', myThingGotClicked);
But this doesn't work. Stepping through in a debugger, you can see that it does actually bring up the menu on a mousedown, but then something immediately hides the menu. At full speed, it looks like nothing happens at all.
Any thoughts?
The problem is that the MenuManager class listens for the mousedown event at the document level and hides all visible Menu instances. So, since you are building a unique sort of Menu implementation, you'll need to stop the propagation of the mousedown event inside your handler so that the MenuManager doesn't handle the event. Here is some pseudo code for you:
var myThingGotClicked = function (event) {
YAHOO.util.Event.stopPropagation(event);
// Do other stuff
};
YAHOO.util.Event.on(myClickTarget, 'mousedown', myThingGotClicked);
Todd
That's a bit closer, as the menu does pop up, but if you try to make a selection in the menu, the text selection of the page underneath goes sort of nuts. I also need to add a mouseup handler, I think, as the menu doesn't go down on mouse release.
What I really want here are menus that work like menus on every version of the Mac OS (until more recently when OS X added the "click to make the menu 'sticky' to the default behavior).

Resources