LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 02-21-2017, 07:46 AM   #1
dancer_69
LQ Newbie
 
Registered: May 2011
Posts: 16

Rep: Reputation: Disabled
Add zoom in/out to mouse middle button and wheel


Hello,
I'm trying to use mouse' s middle button and wheel to zoom in/out in google chrome. This future is activated on google chrome by holding ctrl key on keyboard and scroll wheel up/down. I tried using xbindkeys and xte like this:

Code:
#mouse zoom
"xte 'keydown Control_L' &"
    b:2

"xte 'keyup Control_L' &"
    b:2 + Release
This worked for some time(not always) but now doesn't work. My intention was to click once the middle button to simulate ctrl hold and click a second time to deactivate it(like a toggle). The most of the times works on first click, but I cannot disable it afterwards or doesn't activated at all.
So expected behaviour is to use the middle button as a toggle button for ctrl. In first click activate control and I can zoom in/out, the second deactivate it to scroll up/down as usual.
Does anybody know how can I achive this with xbindkeys or with other ways?
Also It would be nice if I could assign this function to a specific mouse only(a logitech wireless mouse which has this future on windows by its program)and not for every mouse input is connected.
Thanks in advance
 
Old 02-22-2017, 08:43 PM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
mouseclick i

pseudo code
Code:
if (i) {
Control_R = false
else
Control_R = true
}
real code
Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  if (CheckBox1.Checked) then
      CheckBox1.Checked:=false
  else
      CheckBox1.Checked:=true;
  end;

Last edited by BW-userx; 02-22-2017 at 09:02 PM.
 
Old 02-23-2017, 01:44 AM   #3
dancer_69
LQ Newbie
 
Registered: May 2011
Posts: 16

Original Poster
Rep: Reputation: Disabled
Thanks for the answer but I cannot understand where and how to use this.
From psudo code I can understand that it's a way to keep track of mouse button if is clicked or not.
But the real code how can be used? Where to put it?
Can you please explain it? Thanks.
 
Old 02-23-2017, 08:16 AM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
That is pascal it will not work. It was just a real example of the code logic itself.

the pseudo code is using the actual functions to check and call them. i is for the mouse click and the Control_R is also from the documentation for what you said you are using. you being the user of same said software would be the one who'd have a better chance of figuring this out.

Quote:
Originally Posted by dancer_69
From psudo code I can understand that it's a way to keep track of mouse button if is clicked or not.
You seem to grasp the logic at lest in its minimum form. You can see what it is doing and obtained an almost correct conclusion. It is a means to check the state of not the mouse button itself but what it is controlling. The click fires an action. That action fires another action. Depending on the sate of the thing needing to be acted on. If not on then off. If on then off. regardless which time you clicked the button. It is kind of like a three way light switch.

Where one switch can turn it on or off, and the other switch can do the same.

If the light is on, and you flip the other switch it will turn it off, because it was already on. If you flip the other switch it will do the opposite. Does not matter if the switch is up or down. The action is flipping the switch, the state is if the light bulb is on or off to start with.

the result is if on then off, if off then on.

the process is if the light switch is flipped(clicked), and if light on then turn it off, if light is off then turn it on.


The state of the mouse button is down, or up same as the right and left mouse buttons, where you can check each state of the button as well, and act on it separately. then it checks the state of the thing being acted on. the same process goes forth.

State-> action Boolean logic. (yes or no, 0 or 1 no shades of gray.)

Quote:
If mouse clicked is true then set Control_button state clicked true if the Control_button state is already true, then it sets it false instead.

Now you just need to build up your knowledge base from that. Here are a bunch of links to help you.


https://mike42.me/blog/2014-11-07_us..._your_workflow

https://blog.sleeplessbeastie.eu/201...-and-keyboard/

http://www.linuxjournal.com/article/10808

https://anton.logvinenko.name/en/blo...eystrokes.html

http://askubuntu.com/questions/49992...with-xbindkeys

http://askubuntu.com/questions/10392...eypress-in-xte

https://liquidat.wordpress.com/2013/...dkeys-and-xte/

A little experimentation on your part is going to be required. That should be plenty to keep you going.

keywords 'xte linux examples'

Last edited by BW-userx; 02-23-2017 at 08:39 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
middle mouse button kittaanna Linux - Newbie 7 08-03-2006 08:50 AM
how should i enable the middle button of 3-button mouse ?? b0nd Slackware 1 07-17-2006 02:46 AM
GIMP and mouse wheel (for zoom)?? aldar Linux - Software 2 12-18-2005 09:34 PM
config middle mouse button has wheel function colorLinux Linux - Hardware 1 07-21-2004 01:42 PM
middle mouse button is paste.. but what if i dont have a mid mouse button? kublador Linux - Newbie 4 09-02-2003 08:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 07:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration