Close Quick Panel (window.show_quick_panel) on key release in Sublime Text - plugins

I am new to sublime text plugin development, I am developing a plugin that involves opening a quick panel on pressing certain key binding. I want the panel to be open only as long as the keys are pressed and once the keys are released I want it (Quick panel) to close. I've figured out I can fire the 'hide_pannel' command to close my Quick panel but I want it to fire on release of the key combination.
For example lets say, I want the quick panel on pressing Ctrl+p and I want it to close after I release ctrl.
So I was thinking if I fire 'hide_pannel' command after release ctrl should do the trick, but I couldn't find how I can fire a certain command on key release instead of key press. If there is any other solution or workaround other than what I was thinking please do let me know.

Although you can detect when a key is pressed in Sublime, you can't directly detect when it has been released. Similarly, the modifier keys (Ctrl, Alt, etc) can not be mapped to anything on their own and always require a non-modifier as well. For example, Ctrl+P is allowed, but Ctrl alone is not.
That said, theoretically it's possible to interface with the underlying operating system using a python library that uses native code in your plugin to observe the state of the keyboard.
I'm not aware of any Sublime specific examples of doing such a thing, however. Note also that in doing this you would also have to provide such a library for all of the platforms that Sublime supports (Windows, MacOS, Linux, and 32 or 64 bit versions on Windows/Linux), presuming that you want your plugin to work on multiple platforms.

Related

Using the §-key instead of the TAB key in ALT+TAB with Autohotkey

I have a need to use something else than the TAB key to achieve ALT+TAB functionality in Windows 10. (long story short - I'm using Parallells and remote desktop on a Mac, and need to keep the Remote Desktop setting "Apply Windows Key Combinations" set to "On this computer", so I can't just forward everything to the remote computer).
Using Autohotkey on the remote computer, I thought I could simply do something like
§::Send {Tab}
to be able to press ALT+§ instead of ALT+TAB, and have Parallells ignore it and just forward it as any other key (for example SHIFT+A to type an "A"). But it doesn't seem to work that way, nothing happens when holding down ALT and pressing § except a "pling" sound. Just pressing § alone prints a TAB character if I'm in a text editor.
I tried
^!§::Send ^!{Tab}
as well, same result.
For now I settled on using the following script instead, which lets me press § to bring up the ALT+TAB window, where I can either use arrow keys or the § key to select an application, and then Enter to switch to it:
§::Send ^!{Tab}
This is not bad, but it's annoying to have to use the Enter key to activate the window. So, is there any way to simply replace ALT+TAB with ALT+§ and get the normal functionality of the ALT+TAB window-switcher?
Use the hotkey <!§::AltTab.
<! means left alt and you can read more about AltTab here.
Also, AltTabMenuDismiss might be worth looking into related to the problem you outlined in the comments.

Eclipse Editor consumes AltGr+A even after disabling keyboard shortcut

I use Eclipse and a non-QWERTY keyboard. My # sign is typed through Alt GR+A. This is on Windows 7.
The Eclipse Editor won't let me type an # which is bad.
I disabled the key shortcut Alt+A, it still doesn't work.
# works in other programs and in other windows inside Eclipse (e.G. find, options etc.) but not in Editor.
As this also applies to Alt GR+P (which is my } ) a general solution as to how to figure out what key events get consumed would be nice.
The Eclipse editors use the StyledText widget. This ignores some inputs depending on the platform.
On Windows the widget ignores anything with just Alt or Ctrl or Alt+Shift or Ctrl+Shift. The code claims that Alt Gr should look like Ctrl+Alt and would get through.
On Macs Cmd and Cmd+Shift is ignored.
On Linux / Motif Ctrl and Ctrl+Shift is ignored.
There is a very old Eclipse bug 20953 which sounds like this problem, but it supposed to have been fixed long ago by the code I mentioned.

Eclipse Back/Forward navigation using mouse buttons

There is an addin for Visual Studio called MouseNavi that allows you to use mouse thumb buttons to navigate your history.
Does a similar extension exist for Eclipse?
I don't know of any Eclipse plugin that does this, but assuming you're using Windows:
This one should enable you to do what you want: http://www.highrez.co.uk/downloads/XMouseButtonControl.htm
With that tool you can assign each mouse button a sequence of keys (Alt+Left for example) and because it can be made application specific it won't interfere with other programs where you don't want that mapping.
Alt+Left and Alt+Right to navigate through the latest opened editors.
Also, Alt+L to open up the shortcuts popup, so you can see what's available.
No real mouse navigation control though (not that I know of... at least). Although, should not be very difficult to create one and attach it to the same handlers that deal with the navigation commands.
^Q takes you to last edited location. You can cycle using it. No mouse bindings.

Faster way (keyboard shortcuts?) to use quick fixes in Eclipse?

I often use the Eclipse feature (Galileo) of suggested error corrections to automatically create code stubs or to refactor things. For example, I would write a method that calls other methods which don't exist yet, then move the mouse over the error message and click on "create method". Or, change this to the class name and choose "add static modifier" from the quick fixes.
I think this is very convenient because it lets me stay in one place in my code and sort of "remotely" wire up what's not currently visible on my screen. What I think is annoying though, is that I have to leave the keyboard, hover my mouse over the error symbol, wait for the tooltip to pop up, and click on the option (doing that, I sometimes move the mouse a little over the edge and the tooltip goes away again - very annoying).
Am I missing a faster method here? I can't seem to find a keyboard shortcut, but then I have overlooked stuff from the huge preference dialog before.
Ctrl+1 : Quick Fix.
(Cmd+1 on Mac)
Just put your cursor on the part you suspect you can perform an action (correction, refactoring, ...) and hit the Quick Fix shortcut. The same popup will be displayed, and you can select the right option with the up and down keys.
That, combined with Ctrl+3 (Quick Access) gives you most of eclipse features at your fingertips ;)
See also:
Eclipse Tip: Shortcut to Quick Fix
My Favorite Eclipse Shortcut: Quick Fix
Eclipse hotkeys: eclipse shortcuts gold mine.
As an additional tip, a specific type of quick fix I use all the time has a dedicated shortcut:
Alt+Shift+J: Add Javadoc comment stub for current method.
After using ctrl+1 like mentioned in the top answer, press ctrl + enter to apply the selected fix all to problems of the same category.
In general, keyboard shortcuts in IDEs (and code tools in general) are coming from a user principle that holds that the more your hands/fingers can remain poised over the keyboard (as in the f-j centered "touch typist" position), the more productive you can become. This is probably why the use of the number keypad is not encouraged, or other keys, less common to the most basic layout keyboard, are not used. Many hold that useful keyboard shortcuts should be easily reachable from this position.
One thing I will say about eclipse keyboard shortcuts is that if you use a popular Windows presentation utility called Zoom-it, you need to turn that off when using eclipse. There are several show-stopper conflicts between the two, such as Ctrl-1 and Ctrl-3.

Eclipse Keyboard shortcuts in Mac OSX

I'm running Leopard and do all my Java development in eclipse. Some of the shortcuts work such as Command-1 which will do a quick suggest. However how do I get the Function Keys (F5 for refresh in the package explorer) to work? Right now it brings up spaces or whatever System Preferences maps to that.
What about Control-click into a breakpoint when I'm debugging and want to go directly to the chosen function? Is there a way for my eclipse keyboard shortcuts to take precedence over other programs?
i'm running eclipse 3.4 though I've had this problem since eclipse 3.2.
Its been a while since I used eclipse on the mac but I think you have to go to Preferences.app and check the "keyboard" pane. There should be an option that chooses if its Fn-function-key or just function-key for the key press. After that, it would be Fn+F5 for expose and just F5 for F5. You will lose the ability to dim the screen and adjust the sound from the keyboard.
In system preferences under keyboard there is a toggle to turn the f keys into real function keys
Are you using a macbook? In OO.org at least, you have to press fn-fx to get at the application short-cut, otherwise you get the system-wide one.
This doesn't sound like an Eclipse problem.
Are you using an External Keyboard or a macbook ?
If you want to use the debuggers and stuff, you need to change the interpretation of the function keys. You have to manually hit the FN key on your laptop keyboard. Some external keyboards have a function lock.
What about the control click and going directly to the function? That works on the windows version of eclipse, but I can't seem to get it working in Mac OSX.
Tried:
command click = nothing
option click = nothing
control click = opens context menu (like clicking the right mouse button)
You can change system level default behaviour from preferences as #sorin explained. A correction to the claim in the last sentence,
"You can use Fn-function-key to dim the screen and adjust the sound from the keyboard."
for making function keys work for external keyboards by default (and not having to push the extra fn key):
Change the default function key behavior
Choose Apple menu  > System Preferences.
Click Keyboard.
Select "Use F1, F2, etc. keys as standard function keys on external keyboards".