How to get menu item selected event in Carbon - menu

I'm trying to handle events related to clicking on or pressing enter on a menu item using the Carbon API in OSX (Cocoa is not an option).
I know about EventTypeSpec and kEventClassMenu and i've dug through the header files looking for the relevant kind constant to use, but i'm still a bit confused as to how I respond to the selection of a menu item. Do I need to handle a key down or mouse down event at the same time as a kEventMenuTargetItem? Do I need to handle kEventMenuMatchKey separately for the enter key?

I'm an idiot.. Events caused by menu items are handled by class command. So:
eventTypes[0].eventClass = kEventClassCommand;
eventTypes[0].eventKind = kEventCommandProcess;
will handle menu events.

Related

Check if a webelement is "clickable" before you click it - Selenium VBA

Forgive what is potentially an obscure question.
In the webtable displayed below the following code will click on the highlighted radio button and fire the JS associated with its "click" event.
Set myEle = ch.FindElementById("__M5_1_1_image")
myEle.Click
For reasons I will not bore you with, I am trying to write a function which will check if you can click on this (or another candidate webelement in the table) WITHOUT actually clicking on it as I do not want to fire the associated "click" event at this stage of the code. However, I do want to know that the webelement I have specified will not throw an error or produce no event when I do click it later.
I have tried .ClickAndHold and .ReleaseMouse as tests to see if the same potential errors are returned as with the use of .click, but this does not work. For example I can get a "Element not interactable error" with .click but no error with the other 2.
Going back to the webpage I notice that this (and all the other tables I want to apply this function to) change the mouse cursor from an arrow to a "pointing hand" graphic when you hover the mouse over the correct element (e.g. radio button image in this example). Hence, one method would be to look for the presence of the "mouseover" event in the list of event listeners for the specific webelement - as highlighted right lower pane of the image. Unfortunately I don't have any idea how to check the "event listeners" associated with a defined webelement using selenium and VBA. For example if I fire the mouseover event for a webelement would it return an error if no such event existed or would there merely be no action? I assume it is the later, so can anyone tell me if it is possible to query whether a specific event is associated on the webpage for a defined webelement?

How to identify the sender of a WM_COMMAND message?

I am using VS 2010 c++. I have a dialog window containing an array of 126 identical pushbutton controls sharing the same value for control ID.
When a button is clicked and the host dialog window receives the resulting WM_COMMAND message, how can the dialog window identify which pushbutton is pressed?
I could use 126 different control ID values, but I was hoping for something a little more concise.
Can anyone help?
ID itself means "what identifies" an object. So you will need to have separate control ID.
There has to be something different about each button control to identify a particular one.
If you want to keep the same control ID, then you can keep track of the handle (HWND) of each button that is created and use the LPARAM parameter of WM_COMMAND message to identify the control by handle.
If you are having unique text for each button then you can use the text property also of the button.

Browser add on/extension to intercept data selection then simulate link click and data entry

Background: a third party web application with a requirement on the order page to explicitly guide staff when a certain category of product is ordered.
Normal process:
select product to add order line (click on product image)
New process:
select product to add order line (click on product image)
[add on] simulate click on edit order line
[add on] simulate clear of default additional information form fields
enter additional information and click save
Note that the two steps to be performed by the add-on could be performed by the user however when things get busy or new staff begin is often the case that the order gets processed with the default value.
Any pointers in the right direction would be appreciated.
A multi-browser solution is preferred but not essential.
I am an experienced developer, including web development, but have no experience in browser add on/extension development.
Thanks.
You can make an addon out of this very easily. You addEventListener to the gBrowser and if the event.target is the product element then preventDefault so the click doesnt go thru (you will have to do mousedown and mouseup prevent as well). Then rather get the id of the "edit order line" and do .click() if that doesnt work and you really need to simulate use MouseEvent:
MDN :: MouseEvent
MDN :: Initatite/Dispatch MouseEvent
To enter aditional information get the id of the fields, and set their value. Then get the "Save" button id and then do .submit() or .click()
i said do get id in this post but you can use querySelector and go by css selector
see this page here on how to interact with content in currently selected tab:
https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Tabbed_browser
basically just do gBrowser.contentDocument.getElementById

How to locate event handlers for OK and Help button in mfc?

I am new to MFC. In the project I am working on the dialogs are created in resource file(.rc).
In that there are OK button(id ID_OK) and Help button (id ID_Help). I am not able to find the event handlers for these two buttons. There are other buttons where the event handlers mapped are easily found. If someone teach me how to find those event handlers it would be very helpful.
And how can I find the functions which get called on clicking of the particular button by debugging in visual studio?
Thank you.
Double click the button (shown in rc) opened in Resource View in Visual Studio and you will be automatically placed by Studio where the Event handler is located in your code.
If this does not work, then probably delete the Button with ID's ID_OK and ID_Help in your resource view and again add it to the resource using different ID and then try to generate the event handler by double-clicking those buttons in resource view. This is because sometimes the value of ID's conflict with other ID values and hence Studio is not able to generate the Event-handler for you in that case.
Buttons don't have direct event handlers as in other frameworks (like in C#, WinForms etc). You must use message-maps in MFC.
ID_OK maps to virtual function CDialog::OnOK, you can just write your virtual function implementation. Framework will call it for you. You can also handle this message with WM_COMMAND message entry.
There is no standard resource ID as ID_Help - it is always capital, and has to be always in caps! No one is stopping you from using small letters, though - it for consistency and better readability.
Instead of fiddling with resource files (.RC and resource.h), mapping the same with your dialog class and things like that. I suggest you to go, and learn, without resource file. Start with drawing in frame (circles, filled-triangles whatever). Learn and know why virtual function are there for some messages, and message-maps for other (most) messages.
My two cents.

Extension-Specific Context Menu

I'm trying to add an item to the right-click menu on my extension. I've tried to find a method which would work, but a lot of the results seem to deal with context menus on the actual page, not the extension icon itself. The contextMenus API doesn't seem to work for this, unfortunately.
There is currently no API for that. Head for Chromium Issue 78631 and click the star to cast your vote for it and receive updates by e-mail. In the meantime, you could create a popup with a menu that lists both the primary action and the actions you would have put in the context menu.
(I assume you're trying to add the context menu item to your browser action. Your question is a little ambiguous.)

Resources