Flat/Raised Button Simulation


'Alyce Watson
'use method in your own code, no credit necessary
'please do not repost this demo
'
nomainwin
open "Flat Buttons" for graphics as #1
#1 "trapclose [quit]"
#1 "when mouseMove [raise]"
#1 "when leftButtonUp [click]"
#1 "when leftButtonDown [depress]"
#1 "setfocus"

#1 "down; fill lightgray;backcolor blue"
#1 "place 100 100; circlefilled 30"
wait

[quit] close #1:end

[raise] 'draw box around button so it appears to be up
mx=MouseX:my=MouseY
if (mx>65) and (mx<135) and (my>65) and (my<135) then
    #1 "color white; line 65 65 135 65"
    #1 "line 65 65 65 135"
    #1 "color darkgray; line 135 65 135 135"
    #1 "line 65 135 135 135"
else
    #1 "color lightgray; line 65 65 135 65"
    #1 "line 65 65 65 135"
    #1 "color lightgray; line 135 65 135 135"
    #1 "line 65 135 135 135"
end if
wait

[depress] 'draw box around button so it appears to be down
mx=MouseX:my=MouseY
if (mx>65) and (mx<135) and (my>65) and (my<135) then
    #1 "color darkgray; line 65 65 135 65"
    #1 "line 65 65 65 135"
    #1 "color white; line 135 65 135 135"
    #1 "line 65 135 135 135"
else
    #1 "color lightgray; line 65 65 135 65"
    #1 "line 65 65 65 135"
    #1 "color lightgray; line 135 65 135 135"
    #1 "line 65 135 135 135"
end if
wait


[click] 'remove box by drawing over lines with lightgray
mx=MouseX:my=MouseY
if (mx>65) and (mx<135) and (my>65) and (my<135) then
    #1 "when mouseMove" 'turn off mousemove detection during routine
    #1 "color lightgray; line 65 65 135 65"
    #1 "line 65 65 65 135"
    #1 "color lightgray; line 135 65 135 135"
    #1 "line 65 135 135 135"
    notice "You clicked a button."
#1 "when mouseMove [raise]" 'restore mousemove detection
end if
wait


Home

Source Code

Utilities

Internet

Games

Graphics

Media Demos

Snippets

DLL's

API Resources

Freeware

LB 4 Companion

Mastering LB 3

LB Workshop

Game Workshop

Links

Index