Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 872647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:48:57+00:00 2026-05-15T10:48:57+00:00

It took me a while to realize what was going on with mouse events

  • 0

It took me a while to realize what was going on with mouse events going through my blocking dialog boxes when I closed them, but I finally figured out why. I still don’t know any good way to fix it.

I have a custom dialog box (that blocks the mouse) with a close button. When I click the close button, I remove the dialog box from the scene, but JavaFx is still processing the MouseEvent and now it finds that there is nothing blocking the screen behind where the cancel button was, so that component receives a MouseEvent. How do I make the mouseEvent stop processing when I see that they pressed cancel and remove the dialog box? Or, is there a way to make the removing of the dialog box not happen until after it is done processing the MouseEvent?

Example Code for the problem:

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.shape.Rectangle;
import javafx.scene.input.MouseEvent;
import javafx.scene.control.Button;

var theScene:Scene;
var btn:Button;

Stage {
   title: "Application title"
   scene: theScene= Scene {
      width: 500
      height: 200
      content: [
         Rectangle{
            width: bind theScene.width
            height: bind theScene.height
            onMouseClicked: function(e:MouseEvent):Void{
                              println("Rectangle");}
         },
         Button{
            layoutX: 20   layoutY: 50
            blocksMouse: true
            text: "JustPrint"
            action:function():Void{
                  println("JustPrint");}
         },
         btn = Button{
            layoutX: 20   layoutY: 20
            blocksMouse: true
            text: "Cancel"
            action:function():Void{
                  println("Cancel");
                  delete btn from theScene.content;}
         },
      ]
   }
}

When you press “JustPrint” you get:

JustPrint

When you press “Cancel” you get:

  Cancel
  Rectangle
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:48:58+00:00Added an answer on May 15, 2026 at 10:48 am

    Do you really need to handle onMouseClicked on the rectangle? If you change it to onMousePressed, your problem is gone.

    Apparently, the button need the full mouse pressed/mouse released sequence to do the action but the deletion (or hiding) happens before the second one is intercepted. And it seems that a mouse release event is enough to trigger the onMouseClicked event.
    So if your rectangle is happy with a simple onMousePressed, you have a workaround…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It took me a while to realize that $_SESSION['user'] was changing because I have
I have the following text from an academic course I took a while ago
This took me a while to figure out and I found the answer on
This is probably going to be a really simple explanation, but I'm going to
It took me a while to get soap configured in php. Now I'm just
I took a data structures class in C++ last year, and consequently implemented all
I took the plunge this afternoon and began studying LINQ, so far just mucking
It took me forever to reduce the problem to this. I cannot express the
I recently took my Db initiating code out of the __construct of my Page
I wish to calculate the time it took for an API to return a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.