Is there an elegant way to expand/collapse the items in a GtkTreeView using the keyboard (say, the Enter key)?The view only seems to be responding to mouse clicks by default.I should perhaps connect the
"key_press_event"
signal to the view and in the handler, check
gtk_tree_view_row_expanded ()
and call
gtk_tree_view_expand_row ()
(with corresponding actions for collapse).
The row-activated signal was the better (right) callback choice instead of the key_press_event. Gave me all the parameters need to use gtk_tree_view_expand_row() and gtk_tree_view_collapse_row(). Works as expected.
Related
I have an RCP application where I am creating a view which invokes an instance of the composite.Now my problem is I want to trigger one event as soon as I show the view/composite in the screen.
I tried with addFocusListner(),addMouseTrackListener(),addMouseListner()but unfortunately none of the them gets the control as I move my mouse pointer around the view.Is there any way we can solve it?
Just grab the control you have used to create view and add selection listener on it.
for example if treeViewer is used to create that view then:
treeViewer.setSelection(new StructuredSelection(element),true);
Ensure selection by this treeViewer.getControl.setFocus();
If you want to trigger an event after your view is in focus/launch then you should add a listener to that view e.g IPartListener2for that you need to create a class and implement IPartListener2 interface. you will get more information here
Also if you want only using mouse event then you need to add MouseMoveListener to your view so when mouse pointer on your when mouseMove will call.
e.g. control.addMouseMoveListener(this);
I have a very basic OS X that has a few different elements.
A text field, a table view and a file contents view.
I have a single ViewController.
I'd like to be able to intercept specific key events for each of these elements in the storyboard in my ViewController and change the focus between the different elements.
For example, if the cursor is currently in the file contents view, and I hit ESCAPE, I'd like for the focus to be transferred to the text field.
Or, if the focus is currently on the table view and I hit ENTER, that the cursor/focus is moved to the file contents view.
What's the best way to handle this?
I have tried overriding the keyDown method in the ViewController but with things such as autocomplete getting in the way, I'm not having much luck. I have added a print statement to keyDown to check if the function is receiving events, but it's not always fired.
Update
Except for the specific keys that I want to intercept, I want all other key events to behave as normal. For example, typing in the file contents view, or the text field.
I would highly recommend watching the WWDC talk #145 from 2010, Key Event Handling in Cocoa Applications. It gives an overview of the event delivery mechanism, and several ways of handling events:
Make a menu item or button whose keyEquivalent is the escape key.
Override cancelOperation(_:) or complete(_:), which are the two NSResponder methods which can get invoked by default when the escape key is pressed. (There are other methods for the enter/return key.)
Override sendEvent(_:) in NSApplication or NSWindow to intercept all events and bypass the default behavior.
I have a confusion that only button element shows option for command and most of the other elements do not support this option.
Is it valid only for Button?
And is only Click Event handled by Command?? Because most of the samples i have seen, On clicking button command gets fired.
In case i want command to be fired on other events, then what to do?
Yes, there are some limitations like above. A command cannot be bound with the controls that doesn't implement ICommandSource interface. But you can use Dependency Property to write custom commands.
You can see this and this or googling for more examples.
I find GtkEntry has a default context menu
But I really do not want it, how can I disable it
I googled but no effective way found
Did you try to just hide/unref/destroy the wigdet passed (the GtkMenu being spawned) within a signal handler hooked to populate-popup?
Another option would be to filter out all right click events by hooking up to GtkWidget's (actually yout GtkEntry which is a subclass of GtkWidget) clicked signal and returning TRUE (for being handled)
I want to develop a site which is easy to use from a Playstation 3 PS3 game console web browser. I thought it would be good to make screen actions on button presses on the console.
I can find no information on how to do this after quite a bit of searching.
Any info or links highly appreciated!
Why not write a function that displays a message for every "keystroke" and you'll see what values they represent:
$(document).keypress(function(event) {
alert(event.which);
});
Then you can use the number you get from this test and create some logic based on that.
Like this perhaps:
if(event.which == 13) {
// display cool menu maybe?
}
From what I've tested so far, the left stick generates mouse events, left pad with arrows generates keyboard events corresponding to arrows, while the right stick generates a mouseevent but unfortunately it does not move the mouse, but rather scrolls the window.
I do not know how to detect in which direction the stick is pushed (unless the cursor actually moved or the background scrolled, in which cases it is quite trivial).
Check: http://vanisoft.pl/~lopuszanski/public/ps3/