How to handle the middle mouse button?


Gibbs

I have an ember component that generates a set of user groups. When the user clicks on one of the list components, it calls the linkAction defined in that component and takes the user to the specific page associated with that list item. However, when the user middle-clicks the component, it takes the user to /# by default, and I can't figure out how to handle this behavior.

For reference are the components shown in the template.

    {{student-group-item linkAction='drillToGroup' drillId=teacherGroup.id
                group_name=teacherGroup.studentGroupName
                meta_class="quiz-item-meta"
                item_1_title= teacherGroup.numStudentsDisplay
                item_1_class="group-count"
                item_2_title=teacherGroup.createdDate
                item_2_class="created-on"
                item_3_title=teacherGroup.shortDescription
                item_3_class="group-desc"}}

And the drillToGroup action does the following

drillToGroup: function(id) {
  this.transitionTo('student-group',id);
},

How can I make this component responsive to the middle mouse button?

handle

This answer is for Ember 2.xx and was written since version 2.15.

By default, the shutdown event receives the event as a parameter by default. For whatever reason, mousedown detects middle clicks . Regular onclick doesn't.

In your template:

<button onmousedown={{action "clicked"}}>button</button>

In your component js:

actions: {
  clicked(event) {
    console.log(event.button)
    // do things based on button value of 0, 1, or 2. 1 is middle.
  }
}

You can read more about event handling in Ember in the Guide . The button property of the click event can be found in the MDN docs .

Be careful when overriding the middle and right mouse buttons. In some cases this can cause issues with the UI. There is no direct equivalent for touch/mobile devices, and many mice don't have wheels.

Related


How to handle the middle mouse button?

Gibbs I have an ember component that generates a set of user groups. When the user clicks on one of the list components, it calls the linkAction defined in that component and takes the user to the specific page associated with that list item. However, when the

How to handle the middle mouse button?

Gibbs I have an ember component that generates a set of user groups. When the user clicks on one of the list components, it calls the linkAction defined in that component and takes the user to the specific page associated with that list item. However, when the

How to handle the middle mouse button?

Gibbs I have an ember component that generates a set of user groups. When the user clicks on one of the list components, it calls the linkAction defined in that component and takes the user to the specific page associated with that list item. However, when the

How to map the middle mouse button for double click?

Kira Ubuntu 18.04. When I click the middle mouse button, it should double click. thanks. Edit: Using the Unity desktop. unknown OS: Ubuntu 18:04 Required packages: xdotoolandxbindkeys you can install these packagessudo apt install xdotool xbindkeys gedit .xbin

tkinter: How to autoscroll with middle mouse button?

哈格(Haggar) Right now, I have an implementation that does two things with the middle mouse button: Scroll the wheel to zoom in and out Roll the wheel button to scroll (pan) left, right, top and bottom. But in this function, I keep pressing the scroll button to

How to enable middle mouse button in Ubuntu 16.04?

Eli Erding The issue is specific to the solution in the given version (16.04). Feel free to mark this as a duplicate, but it was created for the latest version user's solution. We can't simply google any solution for 16.04 and keep looking for it . Ok, I try t

How to enable middle mouse button in Ubuntu 16.04?

Eli Erding The issue is specific to the solution in the given version (16.04). Feel free to mark this as a duplicate, but it was created for the latest version user's solution. We can't simply google any solution for 16.04 and keep looking for it . Ok, I try t

How to disable middle mouse button click?

hardcode My mouse is faulty and the middle mouse button is always pressed, but I don't know how to disable the click function. I've looked at the mouse settings, but I can't change the function of the middle mouse button at all. I still want to be able to scro

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 detect middle mouse button click?

Nate All the questions I've seen about how to detect the middle mouse button in JavaScript are related to jQuery, but I would like to know how to use regular JavaScript to detect a middle mouse button click. I tried using onClick(), but it only seems to work w

How to detect middle mouse button click?

Nate All the questions I've seen about how to detect the middle mouse button in JavaScript are related to jQuery, but I would like to know how to use regular JavaScript to detect a middle mouse button click. I tried using onClick(), but it only seems to work w

How to simulate middle mouse button in selenium?

Ovicon So, I'm inside a google classroom with 8 classes and I want selenium to middle click and open those classes in a new tab. For example, here is one of my classes, I have it find an element by xpath, I want selenium to open this element in a new tab by mi

How to detect middle mouse button click?

Nate All the questions I've seen about how to detect the middle mouse button in JavaScript are related to jQuery, but I would like to know how to use regular JavaScript to detect a middle mouse button click. I tried using onClick(), but it only seems to work w

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

tkinter: How to autoscroll with middle mouse button?

哈格(Haggar) Right now, I have an implementation that does two things with the middle mouse button: Scroll the wheel to zoom in and out Roll the wheel button to scroll (pan) left, right, top and bottom. But in this function, I keep pressing the scroll button to

tkinter: How to autoscroll with middle mouse button?

哈格(Haggar) Right now, I have an implementation that does two things with the middle mouse button: Scroll the wheel to zoom in and out Roll the wheel button to scroll (pan) left, right, top and bottom. But in this function, I keep pressing the scroll button to

How to enable middle mouse button in Ubuntu 16.04?

Eli Erding The issue is specific to the solution in the given version (16.04). Feel free to mark this as a duplicate, but it was created for the latest version user's solution. We can't simply google any solution for 16.04 and keep looking for it . Ok, I try t

How to enable middle mouse button in Ubuntu 16.04?

Eli Erding The issue is specific to the solution in the given version (16.04). Feel free to mark this as a duplicate, but it was created for the latest version user's solution. We can't simply google any solution for 16.04 and keep looking for it . Ok, I try t

How to disable middle mouse button click?

hardcode My mouse is faulty and the middle mouse button is always pressed, but I don't know how to disable the click function. I've looked at the mouse settings, but I can't change the function of the middle mouse button at all. I still want to be able to scro

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 detect middle mouse button click?

Nate All the questions I've seen about how to detect the middle mouse button in JavaScript are related to jQuery, but I would like to know how to use regular JavaScript to detect a middle mouse button click. I tried using onClick(), but it only seems to work w