I need to capture the event that an app throws when you click on the screen, on a list. When I click on the screen, actionPerformeed(ActionEvent e) returns -1, I suppose that it is the default event.
In non-touch devices, the launched event by pressing the central button is Canvas.FIRE, why not in tactile devices?
How can I do that?
The actionEvent source argument will be from the list. Action events are designed to encapsulate the trigger for the action (e.g. key/touch) since that is irrelevant. There is no need to distinguish the trigger since you can always extract the lists selected item and use that.
There are use cases where one would like to know the location touched within the cell renderer but that is a special case unrelated to the question.
Related
In order to block ALL keyboard access, mouse access and keyboard shortcut events in one of my projects, I:
Created a full screen transparent borderless window, in front of other windows, but invisible.
Handle all keyboard and mouse events with simple return; the window itself.
Make the window modal [NSApp runModalForWindow:myWindow] in order to block keyboard shortcuts.
Release window from touchpad's gesture events only.
But this guy made it look simple in a tiny app -MACIFIER:
How did he do it?
not really sure if this would be usable, but you could use the program hotkeynet (generally used for gaming, but I have had success using other methods) and map every single key/mouse action to do nothing. I did something similar by blocking access to a specific program with it in about 20-30 minutes.
not sure if it will help; but it might be the solution you need?
I believe you can use Quartz Event Services. In particular, have a look at CGEventTapCreate, and note the 4th parameter, which allows you to specify what kinds of events you'd like to intercept. The available kinds of events are listed in the CGEventType enum.
If you set your tap to be an active filter, returning NULL from the callback will delete the event.
I have developed an extension for Safari which uses a context menu.
In the code, I am listening to the command event of the context menu item using:
safari.application.addEventListener("command", commandHandler, false);
In the commandHandler() function, I have added an alert statement for debugging purposes. By doing so, I found that the function commandHandler() is firing twice whenever I click on the context menu item.
Also I added a tool bar item, which also fires the command() event on clicking. The function attached to the command() event is also firing twice after clicking on the item.
Does anybody know of this issue and how to resolve it?
Without more information, this sounds like a problem of insufficient filtering. That is, you're receiving all command messages without determining which they are or why they're flowing across your callback layer, and your callback layer receives two messages per click of, as given, unknown disposition.
The event notification callback structure for Safari extensions allows you to register multiple events against the same event type, and multiple distinct events may be generated in many cases. To this end, your attempt to add an event listener to the "command" scope means you're literally receiving all commands passed to the callback layer. These may be multi-firing in cases where you have, for example, a complex nesting relationship (A contains B, where A and B both notify) or a complex behavior pattern (for example, a mousedown followed by a mouseup).
Apple provides guidance on how to handle this scenario, by binding the command to a specific target or specific command, which is what you should do here. And just in case that's insufficient, here's additional documentation on how the callback system works to help you define your events properly.
Following the guidance should allow you to work through this issue by properly binding your events to your object and only operating on the events you need. Everything else should simply be ignored by your event handler.
I have a problem with my mouse. Every now and then it will double click when I only single click. I know this is a problem with the mouse, and I've contacted the manufacturer, still waiting for a reply. But in the meantime I was wondering if there was a way that I could find out when the left mouse button had been clicked twice within a very short period (probably 1-10 milliseconds) of time, and disable the second click.
I mostly know how to use hooks, so that's not the problem, my main question is how to stop an event from happening, if that's possible.
The information on how to prevent the mouse message from being processed is in the documentation of the "LowLevelMouseProc callback function" in MSDN:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644986(v=vs.85).aspx
Specifically, it says: "If the hook procedure processed the message, it may return a nonzero value to prevent the system from passing the message to the rest of the hook chain or the target window procedure." So, if you know about windows hooks, you know how to do it.
EDIT: Actually, now that I think more about it, you don't want to discard any event. You simply want to transform the doubleclick event into just another left-button-down event. I believe you can do it from within the hook handler, and it will work. Have you tried it?
In C#'s WinForms, you write an event handler involving the mouse receiving a MouseEventArgs object. Inside it, you can access certain info such as the number of times it was clicked, for example.
protected void RowClicked(object sender, MouseEventArgs evt)
{
// Trigger it when the mouse was clicked only once
if( evt.Button.Clicks == 1 ) {
// ... more things ...
}
return;
}
Other GUI libraries have other possibilities. That said, your problem has nothing to do with GUI libraries. You have to change the sensitivity of your mouse, in the configuration options of your operating system. For example, in the Windows' control panel, you can change how much time has to pass between a click and another one to be considered a doble-click. In lUbuntu, you can do the very same, in System menu >> Preferences >> Keyboard and Mouse.
As you can see in my previous question, I am currently struggling with single and double click events – I wanted to perform an action after a click and a completely different action after a double click. The problem is that the low-level events only tell me things like this was a mouse down or this was a mouse up and the total click count is == 2. It’s hard to discriminate between a single and a double click this way, since when the mouse comes up after a single click, I have to wait a while to make sure there’s not a second click coming.
Now I am wondering how different GUI toolkits handle this, as there’s no magical way around. You can’t have separate high-level single-click and double-click events without having the single-click event delayed or something, can you?
(It looks like the usual way to solve this is to have the single and double click actions related, like selection on the first click and app launch on the second. That way it does not matter that the single-click action is triggered along with the double-click one. Am I right?)
You always need some sort of timer to distinguish between single and double click. Think about it: you cannot predict whether a second click will happen once the first occurred, you just have to wait and see.
On iOS, you can have gesture recognizers. And if you only register a single tap recognizer it fires right away, but as soon you also register a double tap recognizer you notice that a single tap doesn't fire right away but only after a noticeable delay. Made me change to a a single tap with two fingers in one app because the delay is really annoying.
You could work around the delay if your single click action is undoable or cancelable: do the action when click count == 1, and if click count == 2, revert the action of the single click. Might result in undesired/unexpected UI behavior, though (from a user perspective).
I have a form in VB6 with two combo boxes (cboCustomer and cboItemNumber). When someone selects a value from cboCustomer, I want to populate cboItemNumber with a list of item numbers relevent to the customer selected. What event does VB6 offer that I can use? I've tried _Change and _LostFocus and neither are doing what I need. I find it hard to believe that I'm having such a difficult time finding a list of possible events.
Try the _Click event. This event fires even if the control is't actually clicked on. For example, if you tab in to it and use the up/down arrow keys to change the selected item, the click event still fires.
As G Mastros says, the _Click event is the one to use, since it fires when the selection is changed via either keyboard or mouse.
If you want to see a list of all the events, then use the Object Browser (F2), and search for or browse to ComboBox. Events are shown with yellow lightning bolts in the Members pane.