RepeatButton Behavior: Mouse move releases button?

I’m experimenting with code to monitor when a GUI.RepeatButton button is released. Here is the code as it currently stands:

private var transactionHold : boolean = false;
private var hasTransaction : boolean = false;

function OnGUI () 
    if (GUI.RepeatButton(new Rect(10, 10, 200, 50)
            , "My Button"))
        transactionHold = true;
        hasTransaction = true;
        transactionHold = false;


function Update()
    if (hasTransaction && !transactionHold)
        print("Process transaction");
        hasTransaction = false;

Case 1: I click and hold the button and don’t move the mouse while the button is held down. I get one “Process transaction” message when I release the button.

Case 2: I click and hold the button, then move the mouse around while staying inside the bounds of the button. I get a whole bunch of “Process transaction” messages. While there is no visual indication of it, the button is behaving as if it is being clicked rapidly. If I stop moving the mouse, the messages stop. Move the mouse again, lots of messages.

Case 1 behavior is as expected. But can anyone explain the behavior in case 2?

[EDITED: Updated code to be more concise.]

You can use your own mouse down and mouse up flags to prevent repeated activations of the button although it does sound a bit like undesired / unintuitive behaviour, perhaps you should submit a bug report.

experienced the same … one most likely needs to check the current event, i.e. check if the mouse really sent the mouse-up event.

same issue: GUI.repeatbutton crazy? - Questions & Answers - Unity Discussions

the event you want to check for is EventType.Used

2014, Still Same problem.