Bug 36959 - Shortcuts "ctrl c" and "ctrl v" don't work on the tree elements
Shortcuts "ctrl c" and "ctrl v" don't work on the tree elements
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
2.1
PC Windows XP
: P4 minor (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2005-10-07 10:18 UTC by Noureddine
Modified: 2007-02-21 14:53 UTC (History)
0 users



Attachments
not a real patch just System.out.println (1.71 KB, patch)
2005-12-05 18:14 UTC, Benjamin Francisoud
Details | Diff
replace ctrl+(x,c,v) with alt+(x,c,v) (4.62 KB, patch)
2005-12-05 18:57 UTC, Benjamin Francisoud
Details | Diff
Simple stand alone java main class that reproduce the same issue (7.11 KB, application/octet-stream)
2005-12-06 14:56 UTC, Benjamin Francisoud
Details
Patch to fix ctrl-c, ctrl-v and ctrl-x (4.39 KB, patch)
2007-02-21 04:59 UTC, John Neale
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Noureddine 2005-10-07 10:18:31 UTC
Shortcuts "ctrl c" and "ctrl v" don't work on the tree elements, for exemple if
i want to copy/paste an HTTP Sample from controller1 to controller2 , i can't do
it with the shortcuts.
Comment 1 Benjamin Francisoud 2005-12-05 18:14:02 UTC
Additional informations:

In MenuFactory.addEditMenu(JPopupMenu menu, boolean removable)
with different shortcuts (different from Ctrl+x, Ctrl+c, Ctrl+v), it works fine.

I tried with:
KeyEvent.VK_(2, 3, 4) (not numpad, watch out they don't behave as normal keys,
keyTyped is not call)
and with KeyEvent.VK_G (I desactivated this one because it was use elsewhere)
(this one behave normally)

I added System.out.println and breakpoints in
JMeterTreeListener.keyTyped(KeyEvent e) (WARN: I'll provide the
System.out.println as a patch but it not for real use) but I don't understand
why Ctrl+x doesn't work?!

I tried to replace VK_X with VK_CUT, still doesn't work.

I read (again and again) the KeyEvent javadoc
(http://java.sun.com/j2se/1.5.0/docs/api/java/awt/event/KeyEvent.html), but I
didn't see any special mention of a different behavior with those special shortcuts.

I tried with azerty and qwerty keyboards, still don't work.

The strange thing is that we assign Crtl+x shortcut in
MenuFactory.addEditMenu(JPopupMenu menu, boolean removable):

menu.add(makeMenuItem(JMeterUtils.getResString("cut"), "Cut", "Cut",
KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_MASK)));

But in JMeterTreeListener.keyTyped(KeyEvent e):

if (e.getKeyChar() == KeyStroke.getKeyStroke(KeyEvent.VK_X,
KeyEvent.CTRL_MASK).getKeyChar()) {
System.out.println("YES!");
} else {
System.out.println("NO!");
}

always print "NO!" when typing "Ctrl+x" ?!

>java -version
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
Comment 2 Benjamin Francisoud 2005-12-05 18:14:58 UTC
Created attachment 17152 [details]
not a real patch just System.out.println

do not use in production, it solves nothing.
Comment 3 Benjamin Francisoud 2005-12-05 18:57:07 UTC
Created attachment 17153 [details]
replace ctrl+(x,c,v) with alt+(x,c,v)

A work around is to replace "ctrl" with "alt"

replace ctrl+(x,c,v) with alt+(x,c,v)
replace alt+x for remote_stop_all with alt+j since alt+x is use for cut now
Comment 4 Benjamin Francisoud 2005-12-06 14:56:32 UTC
Created attachment 17158 [details]
Simple stand alone java main class that reproduce the same issue

I reproduce this bug with a simple stand alone swing component using
KeyEventDemo
(http://java.sun.com/docs/books/tutorial/uiswing/events/example-1dot4/KeyEventDemo.java)
as a base.

- run it > type "ctrl+f", "Copy - actionPerformed" is written in the JTextArea
- replace VK_F with VK_C > run it > type "ctrl+c", nothing is written in the
JTextArea

It's a swing issue. I just doesn't work for those special shortcuts...

do you plan to use my previous patch (replace ctrl with alt) ?
Comment 5 Benjamin Francisoud 2005-12-15 09:49:17 UTC
I opened a sun/java bug.

Here's the ref: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6362735
Comment 6 John Neale 2007-02-21 04:59:59 UTC
Created attachment 19618 [details]
Patch to fix ctrl-c, ctrl-v and ctrl-x

Added support for ctrl-c, ctrl-v and ctrl-x to the JMeterTreeListener class.
The keypressed event passes to the ActionRouter to perform the task.
Comment 7 Sebb 2007-02-21 14:53:12 UTC
Thanks very much - latest patch has been applied to the code