Page 1 of 1

MakeButton Error

Posted: Tue May 04, 2021 1:06 am
by ocean77
What exactly is wrong with this line? :

MakeButton(1, #SIMPLEBUTTON, 0, 0, 100, 100, {OnMouseDown = p_DialRotLeft})

Hollywood 9 says the usage/ parameters are wrong, but I can't figure out what it is.

Re: MakeButton Error

Posted: Tue May 04, 2021 10:28 am
by amyren
I think you need to check the rest of your script
Even just adding an empty function will make it run withot errors. Perhaps your function name is misspelled or missing the ()

Code: Select all

Function p_DialRotLeft()
EndFunction
MakeButton(1, #SIMPLEBUTTON, 0, 0, 100, 100, {OnMouseDown = p_DialRotLeft})

Re: MakeButton Error

Posted: Tue May 04, 2021 1:42 pm
by plouf
Ibthink it is wrong error message

Makebutton only works when a bgpic is active (so no when rapagui exist for exmple)

Also these are some restriction when used between flipbuffer() (which i dont really recall atm)

Re: MakeButton Error

Posted: Tue May 04, 2021 5:28 pm
by ocean77
Well this is the complete script (just something I'm testing out)
I don't know what I am doing wrong here... But it's probably obvious. :roll:

Code: Select all

@VERSION 9,0


/*
** Constants
*/

Const #BGCOLOR = $065686

/*
** Variables
*/

dial_min = 1
dial_max = 9

/*
** Brushes
*/

@BRUSH 1, "dial_bkg.png", {LoadAlpha = True}
@BRUSH 2, "dial.png", {LoadAlpha = True}
@BGPIC 1, "bkg.png"

/*
** Display
*/

@DISPLAY {Width = 800, Height = 600, Color = #BGCOLOR}


/*
** Script starts here!
*/

DisplayBGPic(1)
DisplayBrush(1, #CENTER, #CENTER)
DisplayBrush(2, #CENTER, #CENTER)

MakeButton(1, #SIMPLEBUTTON, 0, 0, 100, 100, {OnLeftMouseDown = p_DialRot, OnRightMouseDown = p_DialRot})


Function p_DialRot(msg)
    Switch msg.action
    Case "OnLeftMouseDown":
        DebugPrint("Clicked rotate left")
    Case "OnRightMouseDown":
        DebugPrint("Clicked rotate right")
    EndSwitch
EndFunction


EscapeQuit(True)


Repeat
    WaitEvent
Forever

Re: MakeButton Error

Posted: Tue May 04, 2021 5:55 pm
by amyren
You need to put the makebutton line below the function it calls.

And you probably should change OnLeftMouseDown to OnMouseDown

Re: MakeButton Error

Posted: Tue May 04, 2021 6:45 pm
by ocean77
amyren wrote: Tue May 04, 2021 5:55 pm You need to put the makebutton line below the function it calls.

And you probably should change OnLeftMouseDown to OnMouseDown
Of course... Always put the function before it's called. When will I learn? :lol:

Thanks.