Capture paste action with middle mouse button


Rehan

I'm working on a Linux machine, and unlike Windows, there are two clipboards, the STRG-C and STRG-V clipboards and the clipboard for highlighted text and middle-click paste.

Now I'm trying to capture the paste action because I want to validate the clipboard and prevent illegal input to the text field.

I successfully captured the standard slurry of STRG-V by:

Action action = textField.getActionMap().get("paste-from-clipboard");
textField.getActionMap().put("paste-from-clipboard", new ProxyAction(action, "paste-from-clipboard"));

and the implementation of the ProxyAction class:

    public class ProxyAction extends TextAction
    {
        private Action action;

        public ProxyAction1(Action action, String actionName)
        {
            super(actionName);
            this.action = action;
       }

       @Override
       public void actionPerformed(ActionEvent e)
       {
           action.actionPerformed(e);
       }
   }

My question is, how do I capture the linux specific middle mouse button paste? The code above doesn't get it, and the action "paste" in the jTextfield doesn't solve the problem either.

Carmichael

I want to validate the clipboard and prevent the text field from being entered illegally.

You can use instead of trying to capture the paste key DocumentFilter. Will be called DocumentFilterbefore any text is inserted Document.

This filter will be called whether text is typed in the text field or pasted into the text field.

See the section on how to implement a DocumentFilter in the Swing tutorial for more information.

Related


Capture paste action with middle mouse button

Rehan I'm working on a Linux machine, and unlike Windows, there are two clipboards, the STRG-C and STRG-V clipboards and the clipboard for highlighted text and middle-click paste. Now I'm trying to capture the paste action because I want to validate the clipbo

Paste with the middle mouse button

Sriharsha Kalluru Are there any apps that use the middle button to paste the same text every time? I've seen tools to paste clipboard text, but I want the same text to be pasted every time I click the middle mouse button. Karan With AutoHotkey the following ca

Paste with the middle mouse button

Sriharsha Kalluru Are there any apps that use the middle button to paste the same text every time? I've seen tools to paste clipboard text, but I want the same text to be pasted every time I click the middle mouse button. Karan With AutoHotkey the following ca

Mouse text selection to paste buffer with middle button

Dave Jarvis background I have a Logitech marble mouse trackball with the scroll function configured as follows: #!/bin/bash dev="Logitech USB Trackball" we="Evdev Wheel Emulation" xinput set-int-prop "$dev" "$we Button" 8 8 xinput set-int-prop "$dev" "$we" 8

Mouse text selection to paste buffer with middle button

Dave Jarvis background I have a Logitech marble mouse trackball with the scroll function configured as follows: #!/bin/bash dev="Logitech USB Trackball" we="Evdev Wheel Emulation" xinput set-int-prop "$dev" "$we Button" 8 8 xinput set-int-prop "$dev" "$we" 8

How to enable paste into terminal with (middle) mouse button

count 0 After that apt-get update && apt-get upgrademy middle mouse button paste stopped working on Xserver/12.04.2 LTS. This may also be due to apt-get autoremoverunning after I just ran it, but I can't remember the specific point when it stopped working. Bas

Missing copy/paste middle mouse button functionality

Gilles An unusual Ubuntu 12.04 system. It's built with minimal installation and doesn't have most of the usual Ubuntu graphical elements: no Unity, no Gnome shell, no LXDE, etc. (I use the i3 window manager). Therefore, instructions such as "Go to System > Uti

How to enable paste into terminal with (middle) mouse button

count 0 After that apt-get update && apt-get upgrademy middle mouse button paste stopped working on Xserver/12.04.2 LTS. This may also be due to apt-get autoremoverunning after I just ran it, but I can't remember the specific point when it stopped working. Bas

Missing copy/paste middle mouse button functionality

Gilles An unusual Ubuntu 12.04 system. It's built with minimal installation and doesn't have most of the usual Ubuntu graphical elements: no Unity, no Gnome shell, no LXDE, etc. (I use the i3 window manager). Therefore, instructions such as "Go to System > Uti

Missing copy/paste middle mouse button functionality

Gilles An unusual Ubuntu 12.04 system. It's built with minimal installation and doesn't have most of the usual Ubuntu graphical elements: no Unity, no Gnome shell, no LXDE, etc. (I use the i3 window manager). Therefore, instructions such as "Go to System > Uti

Mouse text selection to paste buffer with middle button

Dave Jarvis background I have a Logitech marble mouse trackball with the scroll function configured as follows: #!/bin/bash dev="Logitech USB Trackball" we="Evdev Wheel Emulation" xinput set-int-prop "$dev" "$we Button" 8 8 xinput set-int-prop "$dev" "$we" 8

How to enable paste into terminal with (middle) mouse button

count 0 After that apt-get update && apt-get upgrademy middle mouse button paste stopped working on Xserver/12.04.2 LTS. This may also be due to apt-get autoremoverunning after I just ran it, but I can't remember the specific point when it stopped working. Bas

How to disable middle mouse button paste in Atom editor?

Rudy Withers I've investigated extensively but have not found a way to disable middle mouse button paste. I found that Auxclick can be disabled, but it doesn't work for Atom editor: atom --disable-blink-features=Auxclick Can you help me? Middle-click paste can

How to disable middle mouse button paste in Atom editor?

Rudy Withers I've investigated extensively but have not found a way to disable middle mouse button paste. I found that Auxclick can be disabled, but it doesn't work for Atom editor: atom --disable-blink-features=Auxclick Can you help me? Middle-click paste can

Which mouse button is in the middle?

Radu Murzea: I'm currently developing a program in Java where a specific event has to be fired only when the user clicks with the left and right mouse buttons at the same time. Since this is a bit unconventional, I decided to test it first. here is: import jav

Which mouse button is in the middle?

Radu Murzea: I'm currently developing a program in Java where a specific event has to be fired only when the user clicks with the left and right mouse buttons at the same time. Since this is a bit unconventional, I decided to test it first. here is: import jav

Disable middle mouse button

Tom Hamilton Stubber So I've tried going through various other questions, but they mostly focus on disabling middle mouse button paste. Basically, the middle mouse button on my Logitech G500s is broken and keeps "clicking" randomly, increasing any chance of do

Disable middle mouse button

Ethan Hunt I need a question to help you, how to disable middle mouse click on any link to open new tab in IE 7,8,9. I have tried many things like return false; e.cancelBubble = true;e.returnValue = false; But there is no way to stop IE's ability to open a Ne

Which mouse button is in the middle?

Radu Murzea: I'm currently developing a program in Java where a specific event has to be fired only when the user clicks with the left and right mouse buttons at the same time. Since this is a bit unconventional, I decided to test it first. here is: import jav

Capture mouse action

Vivid First, some background: I need to develop a web application that will collect all mouse actions of the user in the background (during a visit to a webpage) and store them in a file in a proper format and then have a separate replay application for it use

Back button to middle mouse button

Protect I want to map the "back" button (xev means "button 7") of a mouse (A4Tech X-7) as the middle mouse button. Is there a way to do this? I'm lost in Google and only find how to map buttons to keyboard shortcuts using xbindkeys etc. Operating system: Cento

Back button to middle mouse button

Protect I want to map the "back" button (xev means "button 7") of a mouse (A4Tech X-7) as the middle mouse button. Is there a way to do this? I'm lost in Google and only find how to map buttons to keyboard shortcuts using xbindkeys etc. Operating system: Cento

Back button to middle mouse button

Protect I want to map the "back" button (xev means "button 7") of a mouse (A4Tech X-7) as the middle mouse button. Is there a way to do this? I'm lost in Google and only find how to map buttons to keyboard shortcuts using xbindkeys etc. Operating system: Cento

Why is the middle button mapped to paste?

Marten I'm in love with Ubuntu, but I really hate this feature. I'm a programmer and I've introduced bugs many times because I accidentally pasted some code that wasn't part of it. I still have debugging nightmares. And I can't even turn it off in the "Mouse a

Disable button capture of mouse

Melia My custom creation ContextMenuStripwith Buttonit: ContextMenuStrip _contextMenu = new ContextMenuStrip(); _contextMenu.Items.Add(new ToolStripMenuItem("Item")); _contextMenu.Items.Add(new ToolStripControlHost(new Button())); When I open this context men