Log in
Please log in or register.
Pages: [1]
  Print  
Author Topic: v1.25 - Button gets pressed by "sweeping over" while pressing mouse button  (Read 710 times)
nitram_cero (2bam)
Sr. Member
****
Posts: 473



View Profile WWW
« 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

2BAM
I Hate Islands, SpaceCoffee, Finding Her, Caverns, Explosive Cats, The Duke, Run, A View on Relationships, RabbitClock's Quest
Adam Atomic
Administrator
Hero Member
*****
Posts: 724


hostest w/ the mostest


View Profile WWW
« 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)
Sr. Member
****
Posts: 473



View Profile WWW
« 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

2BAM
I Hate Islands, SpaceCoffee, Finding Her, Caverns, Explosive Cats, The Duke, Run, A View on Relationships, RabbitClock's Quest
nitram_cero (2bam)
Sr. Member
****
Posts: 473



View Profile WWW
« 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

2BAM
I Hate Islands, SpaceCoffee, Finding Her, Caverns, Explosive Cats, The Duke, Run, A View on Relationships, RabbitClock's Quest
UberGeorge
Newbie
*
Posts: 40


View Profile
« Reply #4 on: Fri, Jul 23, 2010 »

Sorry to resurrect such an old thread but this issue has never been fixed!
Logged
goyourside
Newbie
*
Posts: 3


View Profile WWW
« Reply #5 on: Sat, Jul 24, 2010 »

HaHA! I have already seen the great thing!!!
Logged

1331520
Newbie
*
Posts: 8


View Profile
« Reply #6 on: Today at 01:39 AM »

I lightly come lightly go.


_________________________________________________________________________________
The perfect item: cheap uggs and nfl jerseys and uggs for cheap and cheap nfl jerseys
Logged
Pages: [1]
  Print  
 
Jump to: