MOUSE Events on FX 2.0 not working correctly

Hi,
I am trying to capture mouse right click in my Java FX application to show the ContextMenu but couldn't do so.
There are methods available in the API i.e. isSecondaryButtonDown() and isPrimaryButtonDown on MouseEvents to capture mouse clicks but not working.
Both of the above mention methods return false irrespective of right or left click.
I will be glad to see resolution for it.
Thanks in Advance.
Ashish

I have no idea what the context of the code you are writing is, but capturing of MouseEvents works fine for me.
Perhaps you are trying to test mouseEvent.isSecondaryButtonDown() in a MOUSE_CLICKED event handler which will correctly return false after a right mouse click because the click event can't be generated until the button is released (i.e. no longer down).
import javafx.application.Application;
import javafx.event.*;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.input.*;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class MouseEventTest extends Application {
  public static void main(String[] args) throws Exception { launch(args); }
  public void start(final Stage stage) throws Exception {
    // provide some instructions.
    final Label instructions = new Label("Right click anywhere to choose a fruit");
    instructions.setStyle("-fx-font-size: 20;");
    instructions.setMouseTransparent(true);
    // ready a context menu.
    final ContextMenu fruitChoices = new ContextMenu();
    fruitChoices.getItems().addAll(new MenuItem("Apples"), new MenuItem("Oranges"), new MenuItem("Pears"));
    for (final MenuItem menuItem : fruitChoices.getItems()) {
      menuItem.setOnAction(new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent actionEvent) {
          instructions.setText("Enjoy your " + menuItem.getText());
          System.out.println("You like " + menuItem.getText());
    // display the context menu whenever a user clicks inside a node.
    final Rectangle node = new Rectangle(400, 300, Color.LIGHTBLUE);
    node.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
      @Override public void handle(MouseEvent mouseEvent) {
        System.out.println(mouseEvent);
        System.out.println("Secondary button down: " + mouseEvent.isSecondaryButtonDown());
        if (MouseButton.SECONDARY.equals(mouseEvent.getButton())) {
          System.out.println("Choosing fruit");
          fruitChoices.show(instructions, mouseEvent.getScreenX(), mouseEvent.getScreenY());
    // show the scene.
    final StackPane layout = new StackPane();
    layout.getChildren().addAll(node, instructions);
    Scene scene = new Scene(layout); 
    stage.setScene(scene);
    stage.show();
}

Similar Messages

  • HT3887 my bluetooth says 'Not Available' how do i get it to work again. I have restarted the computer several times and have replaced the batteries in both the keyboard and mouse and yet it still is not working! please help

    my bluetooth says 'Not Available' how do i get it to work again. I have restarted the computer several times and have replaced the batteries in both the keyboard and mouse and yet it still is not working! please help

    I have had the same problem. It was cured by turning computer off and/or restarting it. I am not sure  if once was enough. I think shutting down must cut out whatever it is that blocks bluetooth. Good luck

  • The calendar sync is recently not working correctly, not display "All events" but it only displays the last six months for my individual entries. My repeating entires do go back further, though. How do I fix?

    I have an iPad 5.1.1. The calendar sync has started to not work correctly. I have it checked "All events," but it only displays the last two months for my individual entries. My repeating entires do go back further, though. How do I fix?

    HI Jason269. Thanks for your reply, however I wrote that I already have "All events" checked. If All Events is checked and it doesn't diaplay all events, how do I fix? It seems this is a common issue, as I have read many others on here state the same problem.
    I believe my problem occurred when I synced my iMac calendar to my iPad calendar using yahoo. Yesterday, I unsynced them on my iMac controls. When I checked my iPad calendar, all of my old entries reappeared - but only for five seconds and disappeared again. So, the data is saved and still there but cannot be displayed, even when I have All events checked. In fact, it only shows my individual entries for the last two months, but does show all my recurring entries. If I switched to last six months, I will see everything for the last six months. If I switch back to all events, it is only for the last two months.
    As I mentioned, others on here have expressed exactly the same issue, including the two month example and having used yahoo.
    For legal purposes, I need to be able to use the information from my indidual calendar entries in an upcoming court case. So I really need to fix this ASAP!

  • Mouse scroll wheel not working correctly.

    Just installed Firefox 4 and my mouse scroll wheel is not working correctly. When opening the program, I can scroll as normal for about 5/10 minutes. Then, suddenly, the mouse scroll wheel no longer works. I've since found that it is actually scrolling outside of Firefox. E.g. I had Outlook open and it was scrolling through my Outlook even though Firefox was the open window. I checked this multiple times and it always seems to be the case.
    Checked about:config as advised, everything looks correct on the mousewheel settings (i.e everything is set to default). Mouse drivers are up to date. No problems with any other programs. This issue started occurring in Firefox 4 beta. I switched back to 3.6 so I could continue scrolling. Updating to Firefox 4 caused the issue to recur.

    It seems a lot of people are having problems with the Mighty Mouse's scroll ball. I actually thought I was done for after just a few weeks of using my first (wired) one. But here I am years later with my wireless variant, beeing perfectly happy with it (in case you don't know, the wireless Mighty Mouse is a much better option due to it's laser based tracking system). In my experience, getting rid of fluff that interferes with the ball is quite easy on both types. Try blowing really hard directly at the trackball (optionally while you press it down with some pointed device) a few times. Rotate it and repeat as needed. Alternatively roll the mouse upside down on the microfiber cloth that probably came with your Mac.

  • My mouse is not working correctly after upgrade to ITunes 11

    I upgraded to iTunes 11 for WinXP and now my mouse is not working correctly. No double clicks, no right button function and sometimes refuses to do simple left click options. What can I do?
    I've tried new mouse drivers and checking the settings in Control Panel but no joy so far.
    Driving me mad and taking me three times longer to do anything as I look for keyboard solutions.

    I'm facing the same problem too on Windows 8. No mouse clicks (just 'ding' sound whenever trying to click anything).
    I could work around it on Windows 8, but ultimately have to restart my PC to get back mouse functionality.
    I wasn't quite sure which app is to blame, but ultimately concluded it's iTunes 11. As this behaviour always concided with having iTunes running in the background for 15-20 minutes (usually listening to podcasts) and never seems to happen when iTunes 11 isn't running.
    Don't know what to make of this, I'm currently playing my podcasts through Windows Media Player instead. I'll hopefully try running iTunes 11 in Windows 7 Compatibiliy mode to see if that helps.

  • I am using a Application in c dll calling from jni jar by java applet in firefox version 19.0 , the problem is click event message box will not working correct

    I am using a Application in c dll calling from jni jar by java applet in firefox version 19.0 , the problem is button click event message box or popup window will not working correctly. Please any one suggest me the steps to overcome this not responding or slowness in the responding problem of Button click event.

    Hello,
    In Firefox 23, as part of an effort to simplify the Firefox options set and protect users from unintentially damaging their Firefox, the option to disable JavaScript was removed from the Firefox Options window.
    However, the option to disable JavaScript was not removed from Firefox entirely. You can still access it from about:config or by installing an add-on.
    '''about:config'''
    # In the address bar, type "about:config" (with no quotes), and press Enter.
    # Click "I'll be careful, I promise"
    # In the search bar, search for "javascript.enabled" (with no quotes).
    # Right click the result named "javascript.enabled" and click "Toggle". JavaScript is now disabled.
    To Re-enable JavaScript, repeat these steps.
    '''Add-ons'''
    You can alternatively install an add-on that lets you disable JavaScript, such as
    *[https://addons.mozilla.org/firefox/addon/noscript/ No-Script] (to disable JavaScript on a per page basis, as required)
    *[https://addons.mozilla.org/firefox/addon/quickjava/ QuickJava] (to easily disable and enable JavaScript, automatic loading of images, and other content)
    Thank you and I hope this helps!

  • HT2216 I am on OSX 10.7.5 and recently had to reinstall it due to 'mail' not working correctly.  That problem was resolved but now my I can't use the 'right click' function on the apple usb mouse.  Any clues?

    I am on OSX 10.7.5 and recently had to reinstall it due to 'mail' not working correctly.  That problem was resolved but now my I can't use the 'right click' function on the apple usb mouse.  I only have a previous version re-install disc as I bought the latest OSX off the app store.  Any help gratefully received?

    Hmmm, no, no drivers needed, now it sounds like a bad install... unless you might have some old Mouse software installed???
    If 10.7.0 or later...
    Bootup holding CMD+r, or the Option/alt key to boot from the Restore partition & use Disk Utility from there to Repair the Disk, then Repair Permissions.
    If that doesn't help Reinstall the OS.

  • Magic Mouse not working correctly??

    I just installed the new Mountain Lion OS and now my Magic Mouse does not work correctly. First after I log in, I have to turn the mouse off and on then then it will move. When I goto the options menu for the mouse none of the addtional features are there for the mouse including the scrolling. Any suggestions?

    Hi Hunters Dad.  I also had this problem and it turned out to be the bluetooth connection.  After I upgraded, the bluetooth connection dropped off system preferences. 
    To locate your bluetooth connections click on the Apple logo in top left hand corner of screen, select System Preferences and look under Internet & Wireless.  You should see Bluetooth there.  If you don't, then power cycle your computer  (see below).  Afterwards go back to the System Preferences and Bluetooth should be there.
    To Power Cycle my computer Apple support had me  shut down my computer, take out the power cable and all other connections for one minute then plug back in and restart as follows:
    press your computer ON button and then hold down the   p r command option  keys  at the same time until the 2nd chime.  I also have been having long boot ups since upgrading and the chimes didn't come on.  Applecare instructed me to stop holding the keys and the computer eventually booted up.  Lo and behold the bluetooth connections were visible and my magic mouse and trackpad now work fine.
    Hope this works for you.

  • Mouse pointer is not working correctly

    I have a MacBook Pro and the pointer is not working correctly.  It does not work smoothly and it is hard to get it to go where I need it to go.

    Hello billm46,
    Welcome to the Apple Support Communities!
    It sounds like the trackpad on your MacBook Pro is displaying jumpy behavior. In this situation, I would recommend reading over and working through the suggested steps in the attached article. 
    Trackpad or Magic Trackpad is jumpy or erratic - Apple Support
    Have a great day,
    Joe

  • Function keys are not working correctly

    I've been looking all over the various threads and I can't find an answer that solves my problem.
    Here are the details:
    I bought the computer in the U.S. where I live.
    I have a iMac 2.4GHz intel Core 2 Duo  EMC 2133 with a 20" screen. Bought it new in February 2008.
    I have Mac OS X 10.5.8  (I am waiting for my order for OS Snow Leopard to come in!!)
    I have been using a wireless mouse and Keyboard (Love not having cords!)
    Recently, my wireless keyboard got a short and quit working. I went down to the apple store and got a new wireless keyboard.
    I had the computer with me at the genius bar so, yes, the apple employee saw exactly what I have.
    I took it all home got the thing all put back together and got the new keyboard paired up and working with the computer.
    Here are the problems:
    Went to go use the function keys while using iTunes and found they weren't working properly. The F10, F11 and F12 do not control the volume of sound as the keyboard indicates they would, they instead activate dashboard, spaces, and application windows. 
    Following the advice of other threads, I looked over in the system preferences and made sure the "Use all F1, F2 etc." box was unchecked (it was unchecked), things still didn't work.
    I tried the fn key but it appears to not work at all it has no effect on the functioning of the function keys.
    I went under keyboard shortcuts in system preferences and found the F10, F11 and F12 keys, it confirms that those keys control spaces, dashboard and application windows as they are performing but shows no options to either reassign to volume control (as marked on the keyboard) or make the fn key work.
    I've gone back and forth trying various combinations of checked and unchecked boxes to see if anything would work, so far I've come up with nothing.
    A couple more important or interesting facts:
    Yes I have turned off and taken the batteries out of the old keyboard. My bluetooth connection currently shows it as disconnected.
    I have restarted the computer.
    One thing I find odd; when I go under preferences and go to Keyboard and Mouse when I go under the section "Bluetooth" it shows Bluetooth mouse with the name of the mouse and the battery level. BUT nothing is showing up under bluetooth Keyboard, I can't figure out how to change this and don't know if it is contributing to the problem.
    When I go under the bluetooth logo on the top bar I find the mouse and both keyboards referenced, the old keyboard is shown as disconnected and the other two are connected. I have tried to update the device's name but it doesn't seem to let me.
    I have double clicked on the device under bluetooth and it shows the new keyboard as discoverable, paired and connected. Hence, I am using the new keyboard to write this inquiry.
    Please, any assistance would be of great help. I have tried to be thorough in order help narrow the possible problem. Thanks!!

    Hendry
    Just thought I'd let you know.  Our suspicions were correct, it was the OS. After I installed Snow Leopard (10.6.8) all the problems were corrected.  I also updated the RAM from 1 gb to 6 gb. The mac is working all around better. Sorry it took so long to get back to everyone. My superdrive had pooped out. Rather than replace it I got an external drive from OWC connected with firewire 800.  So far everything is running very well, as far as I can tell this external drive is better than the original superdrive. My superdrive has always acted funny, infact I returned the first mac I got after a week because its superdrive was also malfunctioning. Anyway, all that to say everything seems to be fully functioning again.
    Roy
    Re: Function keys are not working correctly 

  • Property inspector not working correctly

    The property inspector in CS3 is not working correctly. When
    I select text or any other object the property inspector does not
    change for that object. But when I right mouse click on the
    selected object it does. Do I need to change a setting?
    Thanks!

    Yes, me too. I can't find an answer to this anywhere.
    If I right-click or double-click on an item the property
    inspector shows it, but if I single click, nothing happens. It's
    bad for productivity.

  • Some time tech pad not working correctly

    I am buy a HP Pavilion laptop from awok.com. Some time mouse teach pad not working correctly some time open windows 8.1 time bar and some time i am using mouse teach pad then automaticly come right click popup menu coming some time i am try to scrol the page using mouse pad then automaticly Select all from the page so please help me

    Hello @BABUMON ,
    Thank you for visiting the HP Support Forums and Welcome. I have read about your HP Notebook and mouse freezing. Here is a document on how to troubleshoot the mouse and Touchpad sensitivities.
    If you will go to the section on Adjusting TouchPad or ClickPad pointing sensitivities it should help resolve the issue.
    I would be happy to assist if needed as there are many models of HP Notebooks, I would need the model number.
    How Do I Find My Model Number or Product Number?
    Please respond with which Operating System you are running:
    Which Windows Operating System am I running?
    Please let me know.
    Thanks.
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the bottom to say “Thanks” for helping!

  • Bootcamp not Working Correctly on Macbook Pro

    Hello,
    I am trying to install Windows 7 or 8 onto my Macbook Pro with Bootcamp.
    Once I have opened the Bootcamp program it all works fine and I can go through the steps perfectly, it will appear to partition the HDD correctly and it will recognise the Windows install DVD correctly.
    However, once my Macbook Pro restarts at the end of the process it boots up and the screen stays white, nothing happens and since I have a gaming keyboard and mouse the lights light up on it for about 5 seconds when it restarts then they go off (Off meaning they aren't powered). The screen will stay white for aslong as I can tell, I left it for 3 hours and the screen was still white.
    So I thought there may be a problem with how it selects the the startup disk, so I boot it up into disk utility then select the DVD again and it stays white, again.
    Anyone know why this is not working correctly? I have tired this with mutliple install DVD's whether they be Windows 8 or Windows 7. I also do not want to use a program that creates a virtual machine, I would like to run Windows 7 to the full so that I can play games with the maximum amount of FPS.
    If you have any questions do not hesitate to let me know.
    Thank you for your time.
    Best Regards,
    Kieran J.

    Does it now work only on battery? or using the power supply?
    If only on the power supply use a grounded plug.
    Otherwise try reseating touchpad cable. Post the size and year of your MBP.

  • Installed new trackpad...not working correctly

    Hi,
    I just installed a new trackpad and it is not working correctly.  The tap to click is not working and it takes extra pressure to even move the tracking arrow.  Any ideas?

    I have an Apple Magic Trackpad I purchased November 2013.  Since upgrading to 10.9 (Maverick) my trackpad will just stop.  My current workaround: turn my Magic Mouse back on (I set it aside in favor of the trackpad), and my trackpad comes back to life.  I turn off the mouse, and the trackpad continues ... for now.
    Strange, and I have no other answers for you.

  • Focus under Win2k does not work correctly

    Hi,
    we've found out that the focus does not work correctly under Windows 2000 in
    Seamless Mode (App is a Windows Application running on Windows Terminal Server
    2003), the same application has no problems under Windows XP, Apple Macintosh
    and Linux.
    Example: The application has a button which pop's up a small calendar window
    giving that window focus. In Tarantella under Win2k however you just see the
    window popping up shortly and then going in the background. As the window is in
    the background and you can't get the window back and you also cannot work
    further in that application as the rest is inactive.
    Only way is to do a right-click on the application in the taskbar, which brings
    the window in the foreground again. What makes this problem even harder to
    analyze is, that it sometimes even works correctly (around 3 of 10 times).
    We've mostly recognized this with modal windows. The native client does not have
    this problem, however as far as I know it does not support seamless mode.
    2. The second problem we got is, that if you click with the mouse into the
    initializing Window while the application starts up after you have clicked on an
    application Link in SGD (I mean the Pre-Login window of Windows which shortly
    shows up just before the Login Process begins),
    the application is not started seamlessly but is started within that window and
    you have no chance but closing an restarting the application to get it in
    seamless mode. This is seen on all Client Operating Systems by us and not only
    Windows 2000.
    The Client runs:
    Windows 2000 SP4 all updates installed
    Java: 1.5.0-5
    Browser: IE6.0 and Firefox 1.0.7
    Server: Windows 2003 Terminal Server (all updates installed)
    Tarantella: 4.20.909
    I hope that someone has at least a workaround.
    Regards
    Carsten

    I have organized some testcases attached are 3 Test Programs which work
    nice natively but got these problems under Tarantella under every Windows
    Operating System (the error is not Windows 2000 as I previously mentioned but
    also occurs on Windows XP).
    The interesting thing is that the Test Program made with .NET does not show this
    problem.
    Could someone please test these and tell if this error is reproducible on your
    systems as well ?
    Run these Testprograms natively, they show no misbehavior.
    Execute this from a SGD Webtop Session in Seamless Mode, see that
    the Modal window is not modal but shifts into the background on every 2 -3 click.
    Regards
    Carsten
    [ModalTestPrgs.zip]

Maybe you are looking for

  • Error while OSB Building on UNIX Machine

    Hi All, I am building OSB Projects on OSB Server on UNIX Machine using ant scripts. The script runs properly on Windows. OSB Version being used is 11.1.1.4. I am getting the following error while creating sbconfig.jar: !SESSION 2011-09-05 11:26:40.42

  • Foreign Currency Revaluation and KDF

    Hi Everyone, For revaluing open items within tcode OBA1 section KDF, what are the criteria's for the accounts that would reside there?  Do all of the below need to be present on the GL master record? 1.  open item managed 2.  line item display 3.  ac

  • When i export schema Packages,function will export or not??

    Hi, i am importing schema so in that schema, i have Packages,function, Procedure, is there, so all packages and proedure etc.. will export or not??? pls tell me sir... Thank you,

  • Application

    Hi guyz, i have an assets application developed in Oracle 10G forms using 9i database. Office guyz can access application, I have an real IP is there anyway that some other branches can access the same application through net? if yes anyone guide me

  • Default mail preference does not work correctly

    I reset my preferences to make mac mail my default, but after a brief time it keeps resetting itself back to the former eudora default. Any ideas how to fix this? Thanks