For the last 2 month I've written application in C# in Visual Studio. Now i have to port that application to Linux by Monodevelop. Well, I already solved most of the porting errors, but there is one that i cant figure out. All double click and mouse double click events from Visual Studio stopped working - I even created small 1-form application that i ported to Mono with only form and one event (double click) - it also didnt work - so that means Monodevelop cant port double click events from Visual Studio ? I already checked WND_Proc function and Linux dont throw up any corresponding double-click event (it was 515 for in window and 3 hundred something on title bar...). Im already giving up and preparing for writing additional code to fix all double-click issue in my code but maybe someone has an answer.
Im using Ubuntu linux (if its neccesary i might tommorow check kernel version), MONO: 2.8.3, Visual Studio 2008 and project in .NET 3.5.
When implementing mouse clicks, there are two main differences between Windows and Gtk# that you should keep in mind:
Gtk# does not offer a 'double-click' signals ('Events' in Windows lingo), but only single 'click' signals. However Gdk library does implements both double-click and triple-click with its EventButton class!
Gtk# differentiates between Widgets (or 'Controls' in Windows lingo) and 'Containers' (there is no direct comparable in Windows). Most widgets placed on a Gtk# form will NOT receive mouse click events. In order to receive a mouse event you need to place the widget inside a specific container - like EventBox.
Here is how you do it Gtk#:
A. Add an EventBox containter to your form (in the example below: eventbox1). You can place it behind other Widgets or since it is not visible, unless you specifically select it to be (or change its background color). You can put a widget inside the EventBox, but you are limited to only one widget, that will also get the shape and size of the EventBox.
B. Add to this EventBox the signal 'ButtonPressEvent' out of the "Common Widget Signals" (in the example below: OnEventbox1ButtonPressEvent)
Every time a mouse button (left, middle or center or a combination) is clicked inside the EventBox, it will trigger this event and the function OnEventbox1ButtonPressEvent() will be called. If you need to identify the button that was clicked while handling this event, use the uint value in: args.Event.Button typically '1' will be the left mouse button, '2' the center button and '3' the right button ('2' might be also when both left and right buttons are clicked).
By the way, mouse motion events (without a button press) are not sent by default. So if you need to sense them you will need to add the PointMotionMask as well in the first like of the code example below.
Here is a code example of the ButtonPress Event Handler (the EventBox name is 'eventbox1') catching a double-click event using the EventButton class:
// The following line is may not be needed but is here to show how to do it
eventbox1.GdkWindow.Events = eventbox1.GdkWindow.Events | Gdk.EventMask.ButtonPressMask;
protected void OnEventbox1ButtonPressEvent (object o, ButtonPressEventArgs args)
{
if( ((Gdk.EventButton)args.Event).Type == Gdk.EventType.TwoButtonPress)
System.Media.SystemSounds.Beep.Play (); // Play a sound only if this is a double-click event
}
The order of the events received (in case of a double click) is:
Gdk.EventType.ButtonPress
Gdk.EventType.ButtonRelease
Gdk.EventType.ButtonPress
Gdk.EventType.TwoButtonPress
Gdk.EventType.ButtonRelease
Hope that helps!
GTK# treats double-click events differently than Windows Forms. You're going to have to write code to translate the events. If you're doing that, you may as well spend the time arguing against double-click as an idiom.
Related
I want to be able to detect using events, when a Window (not necessarily the application I'm creating) changes its title.
My ideas (but none of them uses a specialized event):
Add an event to the mouse click and keyboard strokes, that way I can detect when the title will change, but it's not perfect, since the title may change a few seconds after the last click (e.g. loading a website)
Do some polling only on whitelisted applications
EDIT: I managed to put the EVENT_SYSTEM_CAPTURESTART hook, which captures clicks. It does work for changing tabs, but for loading new pages, it will not capture the change because pages usually take some time to load.
I'm doing this by using UIA (as suggested by Hans). I detect when a new window opens, get the UIA element, and subscribe to the property changed event handler for it for the NameProperty.
Automation.AddAutomationPropertyChangedEventHandler(
<your window AutomationElement>,
TreeScope.Element,
<your delegate>,
AutomationElement.NameProperty);
Good evening folks,
I'm building a simple application (A) that sends Strings to a textbox of another application (B). I was able to this step, but afterwards I'd like to automatically press a button placed just under the textbox. The problem is that I can't get the Handle of the Button; using "Window Detective"(similiar to Spy++), I see only the textboxes (called "TEdit", see the attachments) and no Buttons!. I'd like to add also that there's no only a Button but 3!! So, how could I press a specific Button? Is there another chance to get the Handle?
Program "target"
Window Detective screenshot
Based on the class name TEdit that's a VCL application probably coded in Delphi. The buttons are likely TSpeedButton and non-windowed. You won't be able to send them messages and they are not automatable.
Faced with this your best hope of success is to fake input. Fake the mouse click at the appropriate location on the form. It's not pretty but there's little option.
I'd like to get notified whenever the caret position changed in the active text view. The only thing EnvDTE seems to offer is the LineChanged event, which of-course does not get raised when moving the caret left or right within the same line.
I realize VS2010's Editor Extensibility lets you do this with no sweat, but I need a solution that is backwards compatible with VS2008.
Have you seen this: DTE2 events don't fire
You have to keep a local instance of the Events object, otherwise the event wont fire (I assume because the COM backed Events object went out of scope and was GC'd):
public class MyVSPackage
{
TextEditorEvents _textEditorEvents;
public MyVSPackage()
{
_textEditorEvents = DTE.Events.TextEditorEvents;
_textEditorEvents.LineChanged += (point, endPoint, hint) => //Do something here
}
}
I found a solution. The solution is to create an IOleCommandTarget and register it on the IVsTextView (See the last two bits of code in this blog post (in Herbrew)). Then, each time a command is fired, I check whether the caret position has changed. See also: this blog post - How to intercept key presses in the Visual Studio text editor
I am trying to make a WPF program in VS express C# I have multiple pages/windows.
I have my main page with a nice picture and a button that says 'Start'.
I want this start button to connect to my contents page/window its called 'modules'.
For simplicity (haha) I am also using blend. I get the point of setting the on click event handler in blend then swapping over to VS. but what do I write in the gap to actually get the button to go to the module window/page. I have been reading up in my spare time and still cannot find a simple answer for an absolute beginner. I can find many samples on how to get a button to display " Hi WPF" or whatever using a text box but thats obvisously not what I want.
i want to click the button and the start page/window to change to the 'module' window/page in the exact same way as blend sketch flow changes pages, in sketch flow you can just make the button navigate to the page you want. and that's all i want to do here page1> to > page2 'module'
I want to implement different functionalities for single and double click on image.
I was earlier using Manipulationstarted event .What could be used now?
I am using help from click count
but (e.ClickCount) is not supported
You can do this with the gestures in the Silverlight for Windows Phone Toolkit
e.g.:
<Image Source="filename.png" >
<Controls:GestureService.GestureListener>
<Controls:GestureListener
Tap="GestureListener_Tap"
DoubleTap="GestureListener_DoubleTap" />
</Controls:GestureService.GestureListener>
</Image>
Beware that the tap event will always be called even when the double-tap event is also called. You could attempt to work round this by having a check in the tap event. (You'd need to have a short timer running on a different thread and if the double click isn't tirggered in this time then assume a double click.)
HOWEVER
From a usability point of view, you may make it easier on your users by having a tap event and a context (tap and hold) menu. This will make it much harder for the user to accidentally select the wrong option and it also gets rid of the problem above.
Having an object support both a tap (or click) and double tap event is not common because it's harder to discover or indicate to users and is easy to use the wrong action. Adding a context menu (right click menu on a PC) is the common convention for adding multiple options to users.
There is a ContextMenu also included in the Toolkit.
Shaireen,
Check out my simple blog article here: The simplest way to detect DoubleClick in Silverlight. That should give you the ability to detect both single Click's and DoubleClick's.
Good luck,
Jim McCurdy
You can use Tapped event for single click and DoubleTapped event for double click in windows phone 8.1
Why you don't have your own local counter variable.