|
nitram_cero (2bam)
|
 |
« on: Sat, Jul 25, 2009 » |
|
I can "sweep thru" a button and it gets pressed.
This is a pain to me because I have multiple menues using FlxLayers in a single FlxState. When I switch between those menues, if for some reason the user was still holding the mouse button down, the new button under the cursor get's pressed.
The usual "GUI way" to do it is If you press on a button (inside it's rect), then he sort of "grabs" the clicking focus. If you release the mouse button inside the focused GUI button's rect, then it raises a "click" event. If you release it outside of the GUI button, then it get's discarded (gives you a second chance in case you incorrectly pressed the wrong button)
It could be nice to implement in the future. At the very least that the button callback get's called "on release" or "on just pressed" instead of "if pressed".
Regards -Martín
|
|
|
|
« Last Edit: Mon, Jul 27, 2009 by nitram_cero »
|
Logged
|
2BAMI Hate Islands, SpaceCoffee, Finding Her, Caverns, Explosive Cats, The Duke, Run, A View on Relationships, RabbitClock's Quest
|
|
|
|
Adam Atomic
|
 |
« Reply #1 on: Sat, Jul 25, 2009 » |
|
yea yea I agree, I thought I had fixed this when I revamped the button code, I'll try and remember to test and fix this asap, or least put up a code patch or something!
|
|
|
|
|
Logged
|
|
|
|
|
nitram_cero (2bam)
|
 |
« Reply #2 on: Sun, Jul 26, 2009 » |
|
Thanks!
I think a FlxG.justPressed(FlxG.MOUSE) instead if FlxG.kMouse in the conditionals could solve it.
But the code there is messy and I don't want to fuck it up.
|
|
|
|
|
Logged
|
2BAMI Hate Islands, SpaceCoffee, Finding Her, Caverns, Explosive Cats, The Duke, Run, A View on Relationships, RabbitClock's Quest
|
|
|
|
nitram_cero (2bam)
|
 |
« Reply #3 on: Mon, Jul 27, 2009 » |
|
FIXED!
Changes are in bold:
override public function update():void { super.update(); if(!FlxG.kMouse) /if mouse is not down (globally), it shouldn't be pressed _pressed=false;
if((_off != null) && _off.exists && _off.active) _off.update(); if((_on != null) && _on.exists && _on.active) _on.update(); if(_offT != null) { if((_offT != null) && _offT.exists && _offT.active) _offT.update(); if((_onT != null) && _onT.exists && _onT.active) _onT.update(); }
visibility(false); if(_off.overlapsPoint(FlxG.mouse.x,FlxG.mouse.y)) { if(FlxG.justPressed(FlxG.MOUSE)) { //trigger just ONCE _pressed = true; _callback(); } visibility(!_pressed); } if(_onToggle) visibility(_off.visible); updatePositions(); }
|
|
|
|
« Last Edit: Mon, Jul 27, 2009 by nitram_cero »
|
Logged
|
2BAMI Hate Islands, SpaceCoffee, Finding Her, Caverns, Explosive Cats, The Duke, Run, A View on Relationships, RabbitClock's Quest
|
|
|
UberGeorge
Newbie

Posts: 40
|
 |
« Reply #4 on: Fri, Jul 23, 2010 » |
|
Sorry to resurrect such an old thread but this issue has never been fixed!
|
|
|
|
|
Logged
|
|
|
|
|
goyourside
|
 |
« Reply #5 on: Sat, Jul 24, 2010 » |
|
HaHA! I have already seen the great thing!!!
|
|
|
|
|
Logged
|
|
|
|
|
|
|