Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows][macOS] SimpleButton up/over states incorrect render after MouseEvent.MOUSE_DOWN event with application focus losing #193

Open
itlancer opened this issue Jan 4, 2020 · 2 comments

Comments

@itlancer
Copy link

itlancer commented Jan 4, 2020

Problem Description

Up/over states of SimpleButton not render properly after MouseEvent.MOUSE_DOWN event and application focus losing. Also this issue reproducible even without application 'deactivate' with context menus.

Tested with multiple AIR versions even with latests AIR 32.0.0.89, AIR 32.0.0.144 beta and AIR 33.0.2.338 with multiple Windows and macOS devices with different OS versions with 32-bit and 64-bit AIR applications with captive runtime.
Same problem in all cases.
May be such problems also exists with Android and iOS but I cannot reproduce it.

Tracker link: https://tracker.adobe.com/#/view/AIR-3722067

DisplayObject target of MouseEvent.MOUSE_DOWN doesn't matter in such cases.
Changing stage.focus after "losing focus" doesn't help.
stage.nativeWindow.maximize() after "losing focus" doesn't help.
NativeApplication.nativeApplication.activate(stage.nativeWindow) after "losing focus" doesn't help.
Problem "fixes" after user left click on some display object after problem occurred (see steps below).
It works fine if application "lose focus" after MouseEvent.RIGHT_MOUSE_DOWN or MouseEvent.MIDDLE_MOUSE_DOWN or MouseEvent.CLICK event. (you can simply replace MouseEvent.MOUSE_DOWN to MouseEvent.RIGHT_MOUSE_DOWN in code below to test it)
In code below Event.DEACTIVATE event even doesn't fire. So technically application doesn't lose focus.

Steps to Reproduce

  1. Launch application with code below.
  2. Make left mouse button click (technically it not a MouseEvent.CLICK but MouseEvent.MOUSE_DOWN) on a button at top left corner of application. It show context menu.
  3. Select context menu item (click on "Menu Item"). Context menu will be closed.
  4. Move (roll) mouse over and out SimpleButton.

Application example with sources attached.
mouse_down_losing_focus_bug.zip

package {
	import flash.ui.ContextMenu;
	import flash.events.MouseEvent;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.ui.ContextMenuItem;
	
	public class MouseDownLosingFocusBug extends Sprite {
		private var menu:ContextMenu = new ContextMenu();
		
		public function MouseDownLosingFocusBug() {
			//Init context menu with item
			menu.customItems.push(new ContextMenuItem("Menu Item"));
			
			//Create button
			var upState:Sprite = new Sprite();
			upState.graphics.beginFill(0xff0000);
			upState.graphics.drawRect(0, 0, 100, 100);
			upState.graphics.endFill();

			var overState:Sprite = new Sprite();
			overState.graphics.beginFill(0x00ff00);
			overState.graphics.drawRect(0, 0, 100, 100);
			overState.graphics.endFill();

			var button:SimpleButton = new SimpleButton(upState, overState, overState, upState);
			button.addEventListener(MouseEvent.MOUSE_DOWN, buttonDown);
			
			addChild(button);
		}
		
		//Show context menu when button down
		private function buttonDown(e:MouseEvent):void {
			menu.display(stage, stage.mouseX, stage.mouseY);
		}
	}
}

Actual Result:
Up and over states of SimpleButton doesn't render properly. Other buttons (if will be presented on the stage) also doesn't render up/over states properly when mouse move over/out them.

Expected Result:
SimpleButton correctly render up/over states when mouse move over/out of it.

Known Workarounds

none
*write your own button implementation

@itlancer
Copy link
Author

itlancer commented Jan 4, 2020

Another steps to reproduce this issue with application deactivate event:

  1. Launch application with code below.
  2. Hold left mouse button down (do not release it) on a SimpleButton at top left corner of application.
  3. "Deactivate" application. With Windows device you can simply make Alt+Tab. Application lose focus. Release left mouse button.
  4. "Activate" ("show") application window again. And try to roll mouse over/out SimpleButton.

You will see the same actual result as described in the issue.

Code sample:

package {
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	
	public class MouseDownLoosingFocusBug extends Sprite {
		
		public function MouseDownLoosingFocusBug() {
			//Create button
			var upState:Sprite = new Sprite();
			upState.graphics.beginFill(0xff0000);
			upState.graphics.drawRect(0, 0, 100, 100);
			upState.graphics.endFill();

			var overState:Sprite = new Sprite();
			overState.graphics.beginFill(0x00ff00);
			overState.graphics.drawRect(0, 0, 100, 100);
			overState.graphics.endFill();

			var button:SimpleButton = new SimpleButton(upState, overState, overState, upState);
			addChild(button);
		}
	}
}

@itlancer
Copy link
Author

Issue still exists with latest AIR 33.1.1.620.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants