How to get keyboard shortcut showing in menu without causing double pasting? - kotlin

When I assign the standard keyboard shortcut for paste in my menu, using the keyboard shortcut actually pastes twice because the system automatically performs a paste when that shortcut is used and then it activates the menu item, thereby pasting again. If I do not specify the keyboard shortcut, then the keyboard shortcut still works because it's a system default shortcut but the menu item no longer shows the shortcut in the menu.
For example, if I write this:
menu("Edit"){
item("Copy") {
action {
when (scene.focusOwner){
myTextField -> myTextField.copy()
myTextArea -> myTextArea.copy()
}
}
}
item("Paste") {
action{
when (scene.focusOwner){
myTextField -> myTextField.paste()
myTextArea -> myTextArea.paste()
}
}
}
}
Then both the menu and the Ctrl/Command-V shortcut work fine because the shortcut is predefined in the system but it doesn't show in the menu, as you see below:
screenshot of edit menu, keyboard shortcut notation not visible in menu
If, however, I change the code for the Paste menu item to this:
item("Paste", "Shortcut+V"){.....
then the menu looks like it should:
screenshot of edit menu with shortcut notation displayed
BUT, using the Ctrl/Command-V key combo causes a DOUBLE paste, because first the built-in system shortcut happens, causing a paste to occur, and then the key combo activates the action{} code block in the menu code causing another paste to occur.
How do I either get the action{} code block to only happen when the menu item is clicked by a mouse (while still keeping the shortcut notation visible in the menu item), or disable the system shortcut (preferably the former)?
Any help is appreciated.
(IntelliJ Idea, MacOS X Ventura, JDK-FX 11)

Related

Use a keyboard shortcut to trigger a html-supported window based on the selected text

I would like to add a feature in my editor: users select a text, and click on a keyboard shortcut (e.g., F9), then a window with content by html (eg, a table like this) appears next to the selection, in the end, users move the mouse or press a keyboard shortcut to make the window disappear.
I understand that we could use addDynamicKeybinding or like here to add a keyboard shortcut.
But for the window, it seems that we have only diagnostic window that support html, right? If so, the only use case I know about diagnostic window is by HoverProvider like here, where we need to hover on a text to make the diagnostic window appear.
Does anyone know how to use a keyboard shortcut to trigger a html-supported window, whose content is related to the selected text?

Choose between open declaration/implementation on Ctrl + click in IntelliJ IDEA

Details:
IDE: IntelliJ IDEA 14
O.S.:: Windows 7
If I want to navigate to the declaration of a method I can choose one of the following approaches:
press Ctrl + left click
right click > Go To > Declaration
press Ctrl + B
If I want to navigate to the implementation of a method I can choose one of the following approaches:
press Ctrl + Alt + left click
right click > Go To > Implementation(s)
press Ctrl + Alt + B
In Eclipse, if I press Ctrl and the mouse is over a method, a popup appears and I can choose what to do (go to Implementation/Declaration). If I press "left click" ( Ctrl is still pressed ) the first option will be chosen.
How can I achieve the same / a similar behavior in IntelliJ IDEA ?
There is not a built-in option for this. You would need to configure a custom quick list to do such.
Open the Settings dialog and go to "Quick Lists" (It's under "Appearance & Behavior" in IDEA 14)
Click the add button to the right of the middle pane
Give your list a name
Click the add button to the right of the far right pane (where is reads "no actions")
Add the Go to Declaration action (Main Menu > Navigate > Go to Declaration)
Add the Go to Implementation(s) action (Main Menu > Navigate > Go to Implementation(s))
Click Apply
Go to Keymap in the settings
Under the "Quick List" node, find the Quick List you just created and map a short-cut (keyboard or mouse) to it. You can, of course, remap one of the shortcuts used by the Go to Declaration or the Go to Implementation(s) action
Click OK to close out of the settings and give it a try.
Note that in the quick list that opens, you will have numbers next to each action for quick selection.
Edit:
Adding a screenshot of final quick list for additional clarity
I was looking for the same thing, because I was also used to it in Eclipse. Nevertheless, in 99% of the cases, I went to the implementation. If that's your case too, you may consider changing the Ctrl+click shortcut in IntelliJ:
Open File → Settings... → Keymap
Search for "implementation", and identify the item "Main menu → Navigate → Implementation(s)" in the list
Right-click the item and choose "Add Mouse Shortcut"
Add the Ctrl+click shortcut by making a Ctrl+left click on the window
When hitting the OK button, you have two choises :
Remove the existing shortcut (opening the declaration)
Leave the existing shortcut : In that case, when using then Ctrl+click, both the declaration and the implementation will be opened (at least when they are in different files)
I know this answer comes like 2 years too late, but hopefully it may help others?
EDIT : This shortcut also applies when you want to navigate to the declaration of a super class. Therefore, my "99%" first declared above drops a bit.
I've added the ctrl + right-click as a shortcut to go the declaration (which conflicts with no other shortcut - but you need a mouse with at least two buttons...).
If you select the method and hit Ctrl+T it will show the implementations of the methods. You can click on the options to navigate to that implemented method. Hope this helps.
On mac you can open the implementation(s) with command + option + click. Right -click on the method and check "go to" for the other options and shortcuts you might need.
My IntelliJ (2016.2) shows the declaration of a method (in a PHP interface) as one of the implementations in the implementation popup, so maybe you can do this all from the Implementations popup now.

Change intellij/android studio tool window quick access shortcuts

Is it possible to change the quick access shortcut numbers for a tool window?
i.e. the numbers next to a tool window name, used by the keyboard shortcut to toggle the window, talked about here
Yep. They are listed in Keymap. MainMenu -> View -> ToolWindows.
P.S.: Idea has a nice Find by shortcut function in Keymap settings page, I used it, to answer your question.
In Android Studio, you can change the Keymap this way:
Preferences -> Keymap
Then open Tool Windows. You may need to scroll down to see all the options.
Right-click on the element you want to assign a new key-stroke. Select Add Keyboard Shortcut. Make sure that the rectangle with a plus in it is selected (use your mouse) and press the key-stroke that you want for this item.
Android Studio will warn you if that key-stroke is already assigned. Click OK to reassign that key-stroke to the item. It'll warn you one more time that you will need to remove the previous assignment for that key-stroke. Click Remove to proceed. You should see the updated keystroke in the right-most column.

Intellij - what is this strange selection, and how do I turn it off?

See the screenshot below to see what I mean. Basically, Intellij only highlights the box I draw with the cursor, but leaves the rest of the editor untouched. I have no idea why it happens, and the only way to resolve it for now is to close and reopen the editor. I have observed the same behavior on a Linux box and a MacBook, both when editing Java and PHP files, so I am not sure it's a bug.
The desired behaviour is standard row selection, i.e. highlight all rows which I drag the cursor over.
I think you have enabled 'column selection'.
Option can be toggled via these methods:
Menu Bar -> Edit -> Column selection mode
Document Body -> Right Click -> Column selection mode
Keyboard Shortcut -> ALT + SHIFT + INSERT
The column select mode is enabled, use Alt+Shift+Insert to enable or disable this mode.
Shift-command-8 to toggle it back and forth on OSX.

Dreamweaver shortcut to swap between source and dependent files

Dreamweaver (CS 5.5) displays source code and dependent files as sub-tabs (?).
You can swap between tabs control+shift+tab, but how to swap between source and dependent files?
This issue has bothered me for a long time now, and I am pleased to say I have found a partial solution to it. There is no keyboard shortcut for switching between related (dependent) files, however there is a shortcut called "Go to Source Code", which by default is Ctrl+Alt+`.
Optional: This shortcut (and any other shortcut) can also be edited via the "Keyboard Shortcuts" menu which can be found under the "Edit" tab. To do so, from within said menu, choose the "Dreamweaver Standard" as the "Current set", and click the most left button amongst the 4 buttons at the top, called "Duplicate set". This will allow you to create a duplicate set of Shortcuts, with a name of your choice. Once that's done, you will be able to find the "Go to Source Code" shortcut by selecting "Document editing" from the "Commands" select box. This shortcut should be the second last. To change the keyboard sequence for it, click on it, insert a new "Press key", click the "Change" button and then the "OK" button to accept the changes.
As for switching to related files, this can be done via View->Related Files. This is clearly not nearly as instant as using a designated keyboard shortcut, but remember, the issue was having to use the mouse in order to switch to related files, and this method allows you to do so by using the keyboard alone (Alt+arrows).