Post by Admin on Dec 31, 2019 4:08:51 GMT
Copy and paste this program into BBC BASIC or BBCSDL and you will see how flexible this can be if
you just want to keep button creation simple and interactive.
So you can create a button with a word label and be able to click on it with your left mouse button
and it will echo the label back at you so your program can know it has been pressed.
The most awesome part about this tool, is you can create endless custom buttons easily.
NOTE remember that you MUST look for EXACTLY what is typed in the message. So if you put in "OK " you must include the spaces
when your program is checking later if it was clicked on.
* the width of your label affects the width of your button, so if your button needs wider sides just add spaces.
you just want to keep button creation simple and interactive.
So you can create a button with a word label and be able to click on it with your left mouse button
and it will echo the label back at you so your program can know it has been pressed.
The most awesome part about this tool, is you can create endless custom buttons easily.
NOTE remember that you MUST look for EXACTLY what is typed in the message. So if you put in "OK " you must include the spaces
when your program is checking later if it was clicked on.
* the width of your label affects the width of your button, so if your button needs wider sides just add spaces.
MODE 8
x$=FNbuttonz(100,100,"clearitall"):REM used to clear the private variable in FNbuttonz
REM so it doesnt keep sending the same info to the program
REM Normally it is placed at the end of all the main program before it cycles back to
REM look for more buttons being pressed
REPEAT
x$=FNbuttonz(100,100,"OK ")
x$=FNbuttonz(200,200,"MAYBE CLICK HERE ")
WAIT 10
IF x$="MAYBE CLICK HERE " THEN GCOL RND(15):CIRCLE FILL 200,500,100: x$=FNbuttonz(100,100,"clearitall")
UNTIL x$="OK "
CLG
GCOL 15
MOVE 100,100
PRINT "YOU CLICKED ON THE OK BUTTON WITH YOUR MOUSE !!!"
END
DEFFNbuttonz(X,Y,msg$)
LOCAL initialx%,fi%,reduction%,tx,ty,mx%,my%,mb%,ad%,ady%,c$
PRIVATE st$
VDU 5
IF msg$<> "clearitall" THEN
initialx%=LEN(msg$)
LET tx= X+initialx%+25
LET ty= Y:reduction%=0
reduction%=initialx%/2
reduction%=reduction%*6
IF initialx%<20 THEN reduction%=reduction%/2
initialx%=initialx%*22-reduction%
MOUSE mx%,my%,mb%
ad%=initialx%+8:ad%+=X:ady%=Y-28
IF mx% >X AND mx%<ad% AND my%<Y+8 AND my%>ady% THEN
c$="15"
IF mb%=4 THEN st$=msg$
ELSE c$="7"
ENDIF
IF POINT(X,Y)=0 THEN c$="7"
GCOL VAL(c$):REM um you may ask why I am doing it this way
IF POINT(X,Y)<>VAL(c$) THEN
FOR fi%=12 TO 48
LINE X-3,Y+20-fi%,X+initialx%+8,Y+20-fi%
NEXT
GCOL 0
MOVE tx,ty
PRINT msg$
ENDIF
ENDIF
IF msg$="clearitall" THEN st$=""
COLOUR 0,0,0,0
MOVE 0,0 REM hide that thing
=st$