Announcement

Collapse
No announcement yet.

Right Click in Scaleform?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Booyah! Solved!

    BOOYAH! SOLVED! Check it out: Put something on the stage and call it "button." Then in your ActionScript code, do this:

    Code:
    import scaleform.gfx.MouseEventEx;
    Extensions.enabled = true;
    
    button.addEventListener("click", clickHandler);
    
    function clickHandler(e:MouseEventEx):void
    {
    	switch(e.buttonIdx)
    	{
    		case 0:
    			trace("Left click");
    			break;
    		case 1:
    			trace("Right click");
    			break;
    	}
    }
    When you click that button, you'll get the expected output to your console. Just replace with whatever exactly you want to do.

    Leave a comment:


  • replied
    Bump. Coldscooter, you ever get this working? I'm going to try what limscafo was doing... treating left/right click as the same thing in ActionScript, and letting UnrealScript try to figure out which one was pressed.

    Edit: Also, I need to make the movie intercept input. Where would I need to look in uscript for flagging something before the input gets intercepted in the GFx movie?

    Leave a comment:


  • replied
    Well we gave up on actionscript getting left or right mouse, so we now ask Unreal if it was left or right click this frame:

    Code:
    this.addEventListener(MouseEvent.MOUSE_DOWN, mouseIsDown);
    
    private function mouseIsDown(e:Event) // could be left and could be right
    {
      if(ExternalInterface.call("IsRightMouseDown")) 
      {
         // do right mouse code
      } 
      else
      {
        // do left mouse code 
      }
    }

    Leave a comment:


  • replied
    Bump on getting the right mouse button to register on AS3.

    Leave a comment:


  • replied
    Any way to do this in Actionscript3, because the posted code does not work in Actionscript3 and there is no analog way to register "button" on an actionscript3 eventlistener.

    Leave a comment:


  • replied
    Originally posted by Bob_Gneu View Post
    As another aside, you should probably try to keep your scaleform side thin, that seems to be a primary benefit to frame rates and responsiveness. You can use the FilterButtonInput event to handle triggering of your right click menu.

    Code:
    event bool FilterButtonInput(int ControllerId,
    	name ButtonName,
    	EInputEvent InputEvent)
    {
        if (ButtonName == 'RightMouseButton')
        { ... }
    }
    Thanks for your answer, Bob, It is certainly good to have options when trying to tackle certain problem, cheers

    Leave a comment:


  • replied
    As another aside, you should probably try to keep your scaleform side thin, that seems to be a primary benefit to frame rates and responsiveness. You can use the FilterButtonInput event to handle triggering of your right click menu.

    Code:
    event bool FilterButtonInput(int ControllerId,
    	name ButtonName,
    	EInputEvent InputEvent)
    {
        if (ButtonName == 'RightMouseButton')
        { ... }
    }

    Leave a comment:


  • replied
    Originally posted by Spellweaverbg View Post
    This morning when I woke up and read again your post it struck me that I completely misread it.
    My English Spoken May also be a bit guilty...
    Happy to help you ^^.

    Leave a comment:


  • replied
    Originally posted by Bozor View Post
    Hello Spellweaverbg.
    I think that your problem is an AS problem.
    In Flash, you can easily set a test in your "if ( button == 2 )" statement wich verify where your mouse is. You can use a movieClip.hitTest () eg.
    A thousand thanks Bozor Yesterday night I lost maybe 3 or 4 hours in vain trying to implement the MovieClip.HitTest() into the code of my cursor, since I thought that the clash of the cursor with the buttons should trigger the events. This morning when I woke up and read again your post it struck me that I completely misread it. After only couple of minutes I had flawlessly working recognition of the right clicks. Here is the code, in case somebody wonders in which way it was achieved.

    I had two buttons: one called "Start" (with instance name "Start_btn") and other called "Restore Game" (with instance name "Restore_btn"). "Cursor_mc" is the instance name of my custom cursor movieclip.
    Code:
    import flash.external.ExternalInterface;
    _global.gfxExtensions = true;
    
    var mouseListener:Object = new Object();
    mouseListener.onMouseUp = function(button, target)
    {
    	if (button == 2)
    	{
    		if (_root.Cursor_mc.hitTest(_root.Start_btn))
    		{
    			trace("Start Right Button");
    		}
    		if (_root.Cursor_mc.hitTest(_root.Restore_btn))
    		{
    			trace("Restore Right Button");
    		}
    	}
    };
    Mouse.addListener(mouseListener);
    The conclusion is - never write code when it's late at night, you can make absolutely obvious mistakes.

    Anyway, thanks alot again, you have been tremendous help in my project. I lost 4 or 5 days trying to get around this road block.

    Leave a comment:


  • replied
    Hello Spellweaverbg.
    I think that your problem is an AS problem.
    In Flash, you can easily set a test in your "if ( button == 2 )" statement wich verify where your mouse is. You can use a movieClip.hitTest () eg.

    Leave a comment:


  • replied
    Hey guys, sorry for bringing up old thread, but I feel I should post here. I'm pretty new at Unreal Script and Action Script, but I'm slowly getting where I want to be. Here is my problem: I want to use the right-click functionality from this code (thanks alot, sidstyler!) :
    Code:
    import flash.external.ExternalInterface;
    _global.gfxExtensions = true;
    
    
    var mouseListener:Object = new Object; 
    
    mouseListener.onMouseDown = function(button, target) 
    {
            // button 1 equals left click
    	if ( button == 1  )
    	{
    		trace( "mb1" ); 
             }
    
            // and then of course button two is right click
            else if ( button == 2  )
    	{
                    trace( "mb2" ); 
            }
    }
    
    Mouse.addListener(mouseListener);
    
    stop();
    But when I put it in the first frame of the Actions layer, the function is always active. The thing is, I want every button on my menu to react on right-clicks, but with this code, I can assign only one action to the right-click. My question is: Is it possible to make this code valid only for my buttons, and not for the whole stage?

    I mean, when I right click on my stage, the actions

    Code:
    // button 1 equals left click
    	if ( button == 1  )
    	{
    		trace( "mb1" ); 
             }
    
            // and then of course button two is right click
            else if ( button == 2  )
    	{
                    trace( "mb2" ); 
            }
    to be executed only when I am pressing a button?

    I really hope I managed to explain myself, as I said I'm fairly new regarding UScript and AS. I'll happily read any link you give me, because at the moment I can't find anything suitable in the explanations about ActionScript in the Help file for Flash CS5. Thanks for your answers in advance.

    Leave a comment:


  • replied
    Thank you sidstyler for the code. It works great for me

    Leave a comment:


  • replied
    No Key.isDown(2) state change in UDK on right mouse click

    I am writing a game that wants to handle all input in flash/scaleform, but with some functions (notably right-mouse clicks) to be handled in uscript. I've got most of it working via the usual suspects for onMouseMove() and bCaptureInput = true.

    In the Actionscript side I have a keyListener with a switch(Key.getCode()) statement to handle keystrokes, and have a mouseListener to pick up the left click via onMouseUp and Down. However there seems to be no way of tracking the right mouse click EXCEPT via a method that passes it from UDK to Flash, which can't be done in this case because bCaptureInput is true. Monitoring Key.isDown(2) within an onClipEvent works in Flash but not in UDK for some reason (is always false regardless of button states). Is there something I need to include to get this to work (other than the already included _global.gfxExtensions = true?

    The primary reason for not wanting the information to go from UDK to Scaleform is that I'd rather not mess around with DefaultInput.ini, and I want all keyboard input to be configurable by the user from within the game itself (rather than from something part of the original UDK menu system).

    Help?

    EDIT: The other reason I went with keytrapping in actionscript was to allow me to trap for the alt key by itself, rather than some combination with other keys.

    Leave a comment:


  • replied
    I restart Flash, redo the copy paste and now, it's working... I compare yours and mine code and can't find the difference... There's something really odd here.

    Nevermind... I will do the srv trick (calling AS from UC when mouseDown), it will be more light for the resources.
    Thanks to you all.

    Leave a comment:


  • replied
    show your uc code, there can be a problem in it

    Leave a comment:

Working...
X