I'm having a problem on controlling what touch event should trigger upon touching an object. The problem is, my background has a touch function and it is overlayed by a button, when I tap the button the background also detect a touch function even though I don't want it to happen. How can I make the button only respond when I tap it, or the background only respond when I actually tap on itself.
it's like in Corona SDK you put a "return true" at the bottom of your function to make the touch event only respond on the object rather than going all the way.
found the answer here, Unity docs is really hard to understand especially for beginners, unlike CoronaSDK docs it's very user friendly
here is the link on how to do this:
Credit to guy in here
Related
My Mouse has started to double click on single clicks, and I know this is a somewhat common issue. I am wanting to handle all mouse click events to fix this issue in software. I know "LowLevelMouseProc" has some decent control, but through many Google searches, I just can't seem to find what I need. There are two main functions I need is.
My application to be the first in the "CallNextHookEx" chain (The Main issue).
To be able to deny or force button state changes for on mouse press, and on mouse release.
and I do know about the "Left Mouse Button Fix" program, but it does not handle drags after a phantom click(after Mouse Release it does not allow for Mouse Press)
I would imagine that to filter everything the mouse puts through would take a colossal amount of time to fix a problem that will only get worse.
I know that this isn't a programmer's fix to the problem, but I had a similar trouble. I took an afternoon and fixed my mouse using some instructions I found on the web. I couldn't find the ones I used, but these are great. I would suggest that you have plenty of light and a magnifying glass.
Door number 3 is just buy a new mouse...
Using methods that work in code might be fine but not knowing exactly what is going behind the scene is not such a good feeling. Fees like a gap or incomplete job.
I happened to find ReleaseMouseCapture() and have used in a method (OnMouseUp event) since seemed necessary but I noticed using or not using this method doesn't affect the visual part of my application at least
Can you give me some idea when we should be using it?
Thanks.
MSDN says:
When an object captures the mouse, all mouse related events are treated as if the object with mouse capture perform the event, even if the mouse pointer is over another object.
Depending on exactly what you're doing it may or may not makes sense. We would need some more information. But what it boils down to is, the object that captures it will listen and receive for all events from the mouse. This way you can better organize your mouse logic. For example, Dragging an object around a screen would be perfect for this since the object itself would be getting all the mouse events.
But, if you're only using ReleaseCaptureMouse so not sure why you're using it. Are you using CaptureMouse anywhere?
I use it whenever I write code to capture the mouse, and need to release the mouse capture when I'm finished.
A typical example would be dragging/dropping controls. When I begin a drag operation, I sometimes wish to have the application or a control capture the mouse so any movements made with the mouse are sent to the specific application or control, regardless of the mouse's actual position. When the user releases the mouse button, I need to release the mouse capture so the application/control stops receiving mouse events that its not interested in.
You only need to call ReleaseMouseCapture if you have called CaptureMouse, so in your case it doesn't sound like you need it.
Capturing the mouse means that the control receives mouse messages even when the mouse moves outside of the control's bounds. It is used for things like drag & drop where the drop will occur outside of the control.
I currently develop an application providing the possibility to drag&drop items from one ListBox to an other. This is working perfectly while using a mouse.
However, when trying to do the same with a touch screen (producing genuine touch events) this will not work.
In my logs I see that the TouchDown and Move is actually detected. But the call to System.Windows.DragDrop.DoDragDrop() does not block as it is the case during mouse usage. It immediately returns, so the drag gesture ends right after it started.
I assume that DragDrop.DoDragDrop() is geared for mouse usage only and depends on a MouseButtonDown during the complete process of dragging?!
So, is there an equivalent for using drag&drop with touch events?
Thanks for any hints
OK, sorry.
This is one of these questions which you are able to answer yourself... after some time.
And it even was not related to drag&drop itself.
Just this much:
Drag&Drop was working fine with touch. However, WPF swallowed an exception which occurred while determining a visual for dragging within an adorner. This logic had to be adjusted for touch events...
I'm programming an application consisting of three usercontrols in an main window.
In one of the usercontrols, there's a slider that needs to be controllable by keyboard input. The left arrow should decrease value, right button increase and so on. I have this work, but only when the slider has focus. If some other control has focus, I cant make it work at all.
Is it possible to define "global" hotkeys? IE keys that trigger the same event or function, no matter where the focus is? Hope I've made myself clear enough...
I have never tried this but If you have a command registered at the main window level with keys associated to it that might work. Keep in mind I have never done this but it is some thing you can try. If you are new to commands here is a blog post about it.
I have never rolled this my self but when using the built in past command I actually had to put code in to prevent it from happening in some cases.
I know this probably isn't much help but I hope it is enough to get you started.
Is there any way to check if a drag and drop is in progress? Some method or win32 api which can be checked? I know I can set AllowDrop and use events but it doesn't work in this case. Basically i want to check, with code, if any drag&drop is in progress.
I had a similar question which I answered myself (after some hours messing about) See - How do I tell if a Drag Drop has ended in Winforms?.
Basically if you do as earwicker suggests you need to set the flag when the drag drop begins near the DoDragDrop call. You will need to unset the flag in both the DragDrop event and in the QueryContinueDrag if the QueryContinueDragEventArgs indicate a drop or a cancel.
The GetCapture API function might be a good start. Basically, when a drag operation starts, the source window "captures" the mouse, which means that it will still receive all mouse events even if the mouse leaves the window.
However, applications can also capture the mouse for other reasons, so this is not 100% reliable. You can try it and see how well it works for you. And with applications doing their own drag&drop handling, there's no way to be sure what is going on anyway.
What about QueryContinueDrag event handler http://msdn.microsoft.com/en-us/library/system.windows.forms.control.querycontinuedrag.aspx ?
You can hook a handler to any control and check if there is a ongoing drag&drop operation and then cancel it if you want to.
Ooops, sorry, I just saw that the guy before me already mentioned that. Me bad.
Assuming it's in the context of just your own code, you could identify all the places in your code where a drag/drop happens, and set a global boolean flag to true for the duration of the operation, then back to false after it finishes.
So the next question is, how are drag/drop operations being started in your application?