Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Right Mousedown + Left Mousedown Triggers event and Right Mouse Down Triggers a different event

Community Beginner ,
Dec 19, 2020 Dec 19, 2020

Hi Everyone-

 

I am up against a wall on this conversion project from AS3 to CreateJS.  

 

Scenario:

When the user Right MouseDowns on an object it displays an "Action Window".  However, when the use Left MouseDowns on the object and then Right MouseDowns it displays a different "Information Window".  It works great.  ONCE!

 

When the user colpetes both the Right Event and the Left/Right event ONLY the Left/Right Event will fire.  The Right only event will not.

 

I have tried it different ways to make it work and the other attempt that somewhat worked was similar to the above however, the Information Window would appear with the Action Window.

 

Any help is appreciated as I have been hobbling code to convert a massive amount of flash this year and I am down to two pieces that are tripping me up.  For the record, I am NOT a coder (so my approach may be janky) but it fell into my lap at work. Below is the code:

 

var _this = this;
 
//left click
 
_this.scene3501.on("mousedown", function (evt) {
var e = evt.nativeEvent;
var key = e.which || e.keyCode;
if (key === 1) {
_this.scene3501.gotoAndStop('selected');
_this.t22.gotoAndStop('on');
_this.wp.gotoAndStop('on');
console.log('left');
actionToggle1 = true
console.log('actionToggle1')
_this.scene3501.on("mousedown", leftrightClick3501); 
 
}
});
 
function leftrightClick3501(evt){
var e = evt.nativeEvent;
var key = e.which || e.keyCode;
if ((key !== 1) && (actionToggle1 == true)) {
_this.infoMenu.visible=false
console.log('Leftright');
_this.actionMenu.visible = true
actionToggle1=false
_this.scene3501.removeEventListener("click", rightClick3501);
} else {
console.log ('didnt work')
}
}
 
//right click alone
_this.scene3501.addEventListener("click", rightClick3501); 
 
function rightClick3501(evt){
var e = evt.nativeEvent;
var key = e.which || e.keyCode;
if (key !== 1) {
actionToggle1 = false
console.log('rightONLYscene3501');
_this.infoMenu.gotoAndStop('scene3501')
_this.infoMenu.alpha=100
_this.infoMenu.visible=true
}
_this.infoMenu.x = _this.infoMenu.x = 530
_this.infoMenu.y = _this.infoMenu.y = 200 
// _this.scene3501.removeEventListener("click", leftrightClick3501);
}

 

What is the best way to reset the event listeners?

 

661
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 20, 2020 Dec 20, 2020


this.scene3501.addEventListener("mousedown",downF.bind(this));

function downF(e){
if(this.previousClick==1 && e.nativeEvent.which==3){
leftRightF.bind(this)();
} else if(e.nativeEvent.which==1){
leftF.bind(this)();
}
this.previousClick = e.nativeEvent.which;
}

Translate
Community Expert ,
Dec 20, 2020 Dec 20, 2020


this.scene3501.addEventListener("mousedown",downF.bind(this));

function downF(e){
if(this.previousClick==1 && e.nativeEvent.which==3){
leftRightF.bind(this)();
} else if(e.nativeEvent.which==1){
leftF.bind(this)();
}
this.previousClick = e.nativeEvent.which;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 20, 2020 Dec 20, 2020

Hi kglad,

 

Thank you.  I will try and get back to you.

 

Cap

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 20, 2020 Dec 20, 2020

sounds good.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 20, 2020 Dec 20, 2020

It works.  I made a few tweaks to get the event to fire when the User only clicks the Right button.  It does have a quirk when the user accidently clicks the right button twice, it fires both menues.

 

At this juncter I am going with it as I looked at the original SWF and it does a similar thing.

 

Thank you again for your help.


Cap

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2020 Dec 21, 2020
LATEST

you can handle all right/left click combos in downF, if wanted.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 20, 2020 Dec 20, 2020

"When the user Right MouseDowns on an object it displays an "Action Window".  However, when the use Left MouseDowns on the object and then Right MouseDowns it displays a different "Information Window"."

 

Hold up. You're saying that if the user right-clicks on a symbol they get a context menu, but if they right-click, having previously left-clicked, they get something else? In all my decades of software use, I don't think I've ever encountered any UI convention like that. It sounds like something out of a fighting game. It sounds, from both a usability and discoverability perspective, pretty terrible.

 

Why don't you just combine the two into a single dialog? Or show the info dialog on right click, with a button at the bottom to display the actions? Or vice versa? This would keep the number of required mouse clicks the same, but be enormously simpler for users to understand.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 20, 2020 Dec 20, 2020

HI ClayUUID-

 

If I could do it any other way than I stated I would have.  And I agree with your assessment, however, again this is how the file was build in AS3 for which I have been tasked with converting to CreateJS. 

 

Now I don't feel as bad as I did not getting this to work.  Either way, I have to get it to work as the original (not even going to get into InputText in an Animated MC).

 

Thank you,

 

Cap

 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines