Gtkmm : How to catch right click signal for a Gtk::Table? - pygtk

I'm making an app using GTKMM and I want to know how to catch the right click signal from a Gtk::Table ?
And also how to catch if the Mouse is over a Gtk::Table ?

All GTK+ widgets have the button-press-event and focus-in-event events. You can use the latter, in combination with its complement (focus-out-event) to track if the mouse is inside the widget.

Ok I figured out the solution. I was able to capute the right click by overiding the button press event :
virtual bool on_button_press_event(GdkEventButton* event);

Related

cocoa / objective c : How to know which control is under the cursor?

I am making an application which will detect global mouse events and log the action performed.
For example : If i click on close/minimize button on finder(or any other app like firefox,safari etc) then the app should be able to detect this. Till now i could find the window name under the cursor when click is made. So i can capture mouse click events. But i am not able to find on how to detect exact which button/control was clicked on that window.
I am using NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDownMask| NSRightMouseDownMask ) handler:^(NSEvent *event){ } for capturing mouse events.
So Is there a way i could know which button/control was clicked? Or in case a folder icon is clicked on finder then is there a way to know that selected folder name.
Thanks in advance!
Its simple. Check UIElementInspector example in dev.apple.com mac library. Following is the link:
https://developer.apple.com/library/mac/#samplecode/UIElementInspector/Introduction/Intro.html

Selenium WebDriver how to close browser popup

I am writing tests for a web App using selenium webDriver and came across a scenario where when I try to close the browser I get a popup saying "Are you sure? The page is asking you to confirm that you want to leave - data entered will be lost." with 2 buttons: Leave Page and Stay on Page
How do I click on those buttons?
( ( JavascriptExecutor ) _driver )
.executeScript( "window.onbeforeunload = function(e){};" );
solved the issue for me
IAlert alert = driver.SwitchTo().Alert();
alert.Accept(); //for two buttons, choose the affirmative one
// or
alert.Dismiss(); //to cancel the affirmative decision, i.e., pop up will be dismissed and no action will take place
You can interact with alerts and the like using the Alert API. Switching to the alert and confirm it would look like this (in Java):
Alert alert = driver.switchTo().alert();
alert.accept();
This is also explained in the Selenium FAQ.
def close_all_popups(driver):
driver.window_handles
for h in driver.window_handles[1:]:
driver.switch_to_window(h)
driver.close()
driver.switch_to_window(driver.window_handles[0])
You might try using keyboard events. So once the window pops up:
Tab onto the "Ok" button.
driver.Keyboard.PressKey(Keys.Tab);
You'll have to play around to see how many tab presses are required.
Then hit space.
driver.Keyboard.PressKey(Keys.Space);
Yeah it's sort of a hack, but WebDriver is still pretty immature.
EDIT: This will work for "real" popups, but as another answerer said, maybe not for weird in-page things. Basically, if you can tab to the close button manually, this method should work.
Not sure what is the structure of the popup that you have used.
Here are a few that may work for you if you have used either of as to popup.
If its an alert. you can try:
driver.SwitchTo().Alert()
If its a window that pops up then:
driver.SwitchTo().Window(<windowname>)
For iFrame:
driver.SwitchTo().Frame("iFrmLinks")
Once you get through either of the three then you can access all its internal elements.
Regards
Tahir
I've got the same problem when i have the form of fields and "done editing" submit button, because when Selenium IDE auto-click the javascript function, that responsible to disable confirmation window (leave page or still on it), it does not take "mouseup" mouse event that mean window.confirm still works and auto-pass test was fails. My solution is override javascript function window.onbeforeunload in this case (no need to ask if we know that we do when we record test in Selenium IDE). You can run override script in the Selnium IDE before click on "Save" (or something like this) button through selenium.runScript - it should simple disable the confirmation window.
Command: runScript
Target: {window.onbeforeunload=function(e){};}
You need to handle the unexpected alerts using try catch blocks. Put your code in try block and catch the 'UnhandledAlertException'
Example:
try{
.....
.....
code here
}catch(UnhandledAlertException e ){
driver.switchto().alert().dismiss();
}
Put one of these before the click event:
selenium.chooseCancelOnNextConfirmation()
selenium.chooseOkOnNextConfirmation()

Closing frontmost window in Cocoa in an app without a menu bar

I am building a StatusBar App in Cocoa, therefore I have no menu. Having no menu implies not having a "File > Close" menu item, which normally listens to the shortcut "Command + W".
From my StatusBar App the user may open a window to change the preferences and that's where I'm running into problems: The user can only close the window by pressing the red dot with the mouse. However, like alle applications I want to support the "Command + W" shortcut as well.
At the moment I see two possibilities to solve this issue:
Place an invisible button on the window which listens to the shortcut.
Add an application-wide listener for the shortcut and contact the window manually.
Both solutions feel like a misuse of the system. The first solution can lead to unexpected behaviour (the window closes if the user hits the invisible button by chance) and the second solution will still result in a beep, since the window does not know that it handles such a shortcut.
Is there an elegant way to solve this problem? Since the view should know what to do, a solution with just Interface Builder would be perfect. If there is no elegant way, is there a way to enhance the solutions mentioned?
Thanks in advance!
If you put a File > Close menu item in your MainMenu nib, the shortcut will work, even though the menu isn't visible.
If you choose to implement an app-wide listener for the shortcut instead, you can get rid of the beep by returning nil from the block, so that the original event doesn't get passed on.

How to disable autocompleet intellisence when pressing spacebar in vb.net

While creating test in vb.net i found it pretty annoying when you start typing and autocompleet changes a class to something similar looking even it is a class you don't want.
Image to illustrate :
In the picture you can see I am trying to setup a controller (this controller does not exist at the moment) so when i press the spacebar i will get DienstControllerFacts.
How do you disable this sort of auto-correction?
I can't see your image, but I think this gives you some keyboard shortcuts for dealing with your issue, and this shows you how to modify the settings.
Did you tried to selecting Common tab instead of All tab in the intellisense window?

Easy way to get a wxTextCtrl click event?

Is there an easy way to handle when a user clicks on a wxTextCtrl? After reading the docs wxTextCtrl I see that there isn't a click or double click event. I understand that there is no such thing as "click" events in wxWidgets from the question wxWidgets: Detecting click event on custom controls, so a simple mouse down event will do.
Example answer:
From: wx wiki
textCtrl->Connect(wxEVT_LEFT_DOWN,
wxMouseEventHandler(MyClass::OnClick), NULL, this );
Have you tried to handle the wxEVT_LEFT_DOWN and wxEVT_LEFT_UP events for your text control? Either by adding them to the static message map, or by calling Connect() for the handler methods.
Edit:
Not all events are listed in the documentation of a class. You need to go up in the hierarchy as well, from wxTextCtrl to wxControl to wxWindow. Unfortunately I can find the documentation for the mouse events in neither class. It should still be possible to handle them, even if it is not clearly documented.