Buttons With Borders

Post Reply
User avatar
rbytes
Posts: 1971
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Buttons With Borders

Post by rbytes » Tue Mar 05, 2019 6:16 pm

UPDATED TODAY. Now works on any iOS device

Did you ever wish that you could set the border thickness of your buttons?
The function highlighted in green in the code below will give you that capability. Just don't overdo it!

Tap a button to prove that it works. You should hear a beep. Tap any empty location on the screen to quit.

Code: Select all

/*
Buttons With Borders
by rbytes, March 2019

Did you ever wish that DRAW SIZE would set the border thickness of your buttons?
This function will give you the same result. Just don't overdo it!

Tap a button to prove that it works. You should hear a beep. Tap any empty location on the screen to quit.
*/

set toolbar off
get screen size sw,sh
iostest=0
IF iostest THEN   ' iPhone 6 screen test. Adjust sw and sh for your screen size.
  sw=568
  sh=320
  dev$=""
ENDIF
rw=sw/1024!rh=sh/768
set output font size 18*rw
if rw=1 then
  print!print
endif
shift=20*rw
cr$=CHR$(10)
SET BUTTONS CUSTOM
DRAW COLOR 0,0,0
FILL COLOR 1,1,1
SET BUTTONS FONT SIZE 24*rw
' set print margin
if rw=1 then marg=5 else marg=0
print!print!print tab(13);"STANDARD";tab(39+marg);"BUTTONS WITH BORDERS"
print!print tab(12);"Border: 1";tab(31);"Border: 3";tab(49);"Border: 5";tab(67);"Border: "&INT (18*rw)
button "start" TEXT "START" AT 100*rw,160*rh SIZE 150*rw,50*rw
butt("reset","RESET",3,300*rw,160*rh,150*rw,50*rw)
butt("quit","QUIT",5,500*rw,160*rh,150*rw,50*rw)
butt("oops","OOPS!",18*rw,700*rw,160*rh,150*rw,50*rw)

' touch screen to end
wait: slowdown
if bp("start") or bp("reset") or bp("quit") or bp("oops") then beep
GET TOUCH 0 AS tx,ty
IF tx<>-1 THEN end else wait 

DEF bp(a$) = BUTTON_PRESSED(a$)

'g'
DEF butt(name$,title$,border,x,y,w,h)
  for t=1 to border-1
    Button name$&t Text TITLE$ at x+t,y+t SIZE w-2*(t-1),h-2*(t-1)
  next t
  t=border
  Button name$ Text TITLE$ at x+t,y+t SIZE w-2*(t-1),h-2*(t-1)
ENDDEF
Attachments
DBDA59DA-4D14-4038-B1FB-5570ADAC960E.png
DBDA59DA-4D14-4038-B1FB-5570ADAC960E.png (74.38 KiB) Viewed 125 times
####### Living the colorful life #######

Post Reply