Delphi TMapView: Any way to turn off zoom on doubletap? - ios

I am using a TMapView component in a Firemonkey project. I have eventhandlers that fire when a user double clicks on a marker (and also a separate event for single click). However, everytime double tap on a marker the map automatically zooms, in addition to firing my event. I've been looking through the doucmentation, but I have yet to find a property or method that handles this. So, is there any way to turn off this feature in TMapView.

Related

IDropSourceNotify - how to implement

I want to implement a OLE Drag&Drop feature. Doing this, I have to detect the mouse button is clicked and moved. Than I call DoDragDrop to start the Drag&Drop feature.
To receive the Drag&Drop feature, I have to call RegisterDragDrop before of it to register a window as a target of the Drag&Drop operation. Like the most applications, my main window based on several sub windows: TreeView, ListView, Edit, etc.. With IDropTarget::DragOver I can detect, if the target sub window accepts the Drag&Drop operation. This works fine, if I drag an object from a different application and the mouse cursor shows as well, if the target sub window accept the Drag&Drop operation.
But if I start the Drag&Drop feature inside my application with DoDragDrop the mouse cursor does now change automatically. Why?
So I can use the IDropSource::GiveFeedback method to change the cursor of the target sub window. But I can't find out, which sub window has to change the cursor.
If I'm right, the IDropSourceNotify should provide this informations. But how can I involve this class into the Drag&Drop operation?
Additional, I don't understand, why I have to handle the mouse cursor by my self, if the source window is inside my application - but it will be handled automatically, if the source window is inside an other application.
Last but not least, if I change the cursor of my sub window inside IDropSource::GiveFeedback it will be shown like I changed it. But since the my main thread is inside DoDragDrop I wonder how Windows detect the changed cursor. If I'm right, Windows ask my application with the WM_NCHITTEST message, which cursor should be shown. But how does my application answer this message, while the main thread is blocked inside DoDragDrop?
I'm working with Delphi XE4 on a Window 7 system.
The drop source should not make any assumptions about the drop target - and should never attempt to modify the UI of the target.
In other words: Do not mess with the cursor property of the control under the cursor.
The return value from IDropSource.GiveFeedback instructs Windows to either use the standard drag drop cursors or let you handle that detail yourself.
If you return DRAGDROP_S_USEDEFAULTCURSORS then the standard cursor corresponding to the current drop effect (the parameter passed to GiveFeedback) will be used. If you return S_OK then you can set the cursor by calling the SetCursor API function.
I would recommend that you just return DRAGDROP_S_USEDEFAULTCURSORS.
Actually unless you have a burning desire to learn the inner details of COM based drag and drop I would recommend you Google "drag drop delphi" and use one of the already available libraries.

How to get textfield value in App Inventor without form submission?

I want to know the event in blocks section using which the entered text value can be obtained without a form submission through button.
Let's say user inputs text in mobile phone through keyboard and presses enter. In this case I want some event to trigger and get the value that user entered.
There are 2 events available like lostfocus and gotfocus.
Will these work? Or is there any other good approach for getting text value on pressing enter?
Unfortunately there is no such event like OnEnterPressed available in MIT App Inventor and the events LostFocus and GotFocus will not work in this case.
What you currently can do is
use a button and use the Button.Click event, or
create your own custom keyboard, see also this example
Currently there is a limitation for App Inventor extensions, which only can be used for non-visible components. Later as soon as also visible components are doable, then you could write your own textbox extension and add an event yourself.
Edit concerning the new question in the comments about different screens:
Use different screens wisely
Before starting to create another screen, first you should think about is it really necessary? See also Building apps with many screens and SteveJG's post about advantages/disadvantages, because in only one screen you also can use vertical arrangements to simulate different screens, just set the arrangements to visible = true/false as needed...
You can insert a Clock component that monitors the TextBox1.Text. When it triggers, it checks if the TextBox1.Text has changed and saves it to a variable. When it triggers again, it compares the variable with TextBox1.Text. After the user finishes typing, the variable and TextBox1.Text will be equal and then you can trigger the event like you eanted when the user pressed Enter.
Hope this helps!

Making sure my XNA game has focus before handling mouse and keyboard events

I'm developing a game that is mixed with winforms (for the map editor). The problem I am facing is that even if the main game window isn't in focus, it still receives mouse change events (such as clicking and moving the mouse).
Is there a way to make sure my application is in focus before continuing on to handle these events are is there some kind of built in method?
Thanks!
Use the Game.IsActive property to check if you should deal with mouse and keyboard input.
If you add a reference to System.Windows.Forms you can check if the XNA window is active like this:
if (System.Windows.Forms.Form.ActiveForm ==
(System.Windows.Forms.Control.FromHandle(Window.Handle) as System.Windows.Forms.Form))
{
// Active form is the XNA window.
}

How to tell what device triggered a particular event in Delphi?

I'm wondering if there's an easy way to tell which input device triggered a particular GUI event.
For example: A TButton.OnClick event gets fired. Did the user trigger it with a keyboard press (shortcut, Enter key for default button, space key for a focused button, etc.) or was it triggered with a mouse click? Is there any easy way to tell?
The reason I'd like to know is so that I can implement keyboard usage hints into some of our applications when the user uses the mouse to initiate actions that could also be done with the keyboard. Our systems on the shop floor are in pretty dusty/dirty environments, and mice tend to not hold up so well in them. Also, in many cases, there's simply not that much room for a mouse to be used. (No, keyboards without numeric keypads is not a solution. They're relied on too heavily.)
However, since our apps run in Windows, users tend to simply use the programs like they would at home -- with a mouse. There's nothing particularly wrong with that, but we've worked hard to optimize the input workflow to be keyboard friendly as well. It'd be nice if there was a low-impact way to indicate to our users that there's a way for them to do the things they're doing without having to grab the mouse.
There's no way to tell from within OnClick. However, you can also attach events to a control that will fire when the mouse rolls over it, which would probably be more appropriate for what you're trying to do anyway. Take a look at the OnMouseEnter and OnMouseLeave events. Also, if you really want something specific to happen when the mouse is clicked, you can attach it to OnMouseUp.

How to capture mouse clicks outside of form (like with Code Insight in Delphi)

I like the idea of the Delphi Code Insight window (custom listbox on form without borders basically) where you can click outside of the form and it will close it automatically.
My first thought was to call SetCapture/ReleaseCapture in the FormCreate and FormDestroy respectively. I set the form's caption to X/Y on the FormMouseMove, but it doesn't update the coordinates outside of the form.
If I call SetCapture/ReleaseCapture from within MouseDown and MouseUp, it does update the coordinates as expected, so that proves the concept does work.
I tried other things as well, e.g. post a WM_USER in the OnShow event, and call SetCapture from there, but it still doesn't update the coordinates. I then tried the TApplicationEvents component (OnMessage), but that doesn't work either.
I've read several articles already, but wasn't able to find what I was looking for. Some articles called SetCapture from within the MouseMove, but that doesn't work when the mouse cursor starts outside of the form. Hrm...
The next step would be to use a WindowsHook, but that's where I stopped. I know how to implement one, but it just seems like I'm missing something really obvious here. There must be a simpler way to do this.
Any ideas? :)
Cheers,
Jarno
What you want can be done easier by adding TApplicationEvents to your form and use the event OnDeactivate. That one gets triggered whenever the application loses focus.
Maybe WM_NCHITTEST can help you somehow. As they say, if the mouse is captured, this message is sent to the window that has captured the mouse. So I would capture the mouse for the form and then wait until result of this message is HTNOWHERE, which should mean "out of the window".
But as far as I can remember, this never worked for me fine, so I finally used (as you mentioned) mouse hook.But in my case I've had a lot of components on that popup form and you need to consider messaging for them too.
The implementation I've used (with a little changes) and which works is here.
I had a similar problem (I needed to implement a scrolling windows if the mouse pointer hovered over a special area and I was not able to use SetCapture)
and circumvented it using a timer + GetCursorPos method.
Just do then a ScreenToClient and check if the mouse is within the window.

Resources