Pagina 1 van 1

Mouseover subroutine

BerichtGeplaatst: zo jun 24, 2007 11:13 am
door Gordon
Hier is een tip waarmee eenvoudig een mouseover
subroutine gebouwd kan worden.

Code: Selecteer alles
    NOMAINWIN

    graphicbox #main.graphicbox1, 40, 55, 50, 50
    graphicbox #main.graphicbox2, 200, 55, 50, 50
    Stylebits #main.graphicbox1, 0, _WS_BORDER, 0, _WS_EX_CLIENTEDGE
    Stylebits #main.graphicbox2, 0, _WS_BORDER, 0, _WS_EX_CLIENTEDGE

    open "untitled" for graphics_NSB as #main
    #main "trapclose [Quit]"

    #main.graphicbox1 "set focus; when mouseMove [bleu]"
    #main.graphicbox2 "set focus; when mouseMove [red]"
    #main "set focus; when mouseMove [yellow]"
    wait

[yellow]

    #main.graphicbox1 "down; fill yellow; flush"
    #main.graphicbox2 "down; fill yellow; flush"
    wait

[bleu]
    #main.graphicbox1 "down; fill green; flush"
    wait

[red]
    #main.graphicbox2 "down; fill red; flush"
    wait

[Quit]
    close #main
    end




Gordon

BerichtGeplaatst: zo jun 24, 2007 3:34 pm
door Abcott
Mooie routine van te maken als je het bijvoorbeeld
combineert met de flatbutton van Alyce?

Abcott

BerichtGeplaatst: ma jun 25, 2007 2:15 pm
door anthonio
mooie tutorial.
flatbutton abcott?
ik heb juist het LB conforums afgezocht maar ik kan deze "flatbutton" niet terugvinden.
mss een woordje uitleg of een link naar die post zou handig zijn.

anthonio

BerichtGeplaatst: ma jun 25, 2007 6:15 pm
door Gordon
Misschien bedoelt hij deze listing?
Code: Selecteer alles
'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





Gordon.

BerichtGeplaatst: ma jun 25, 2007 10:27 pm
door anthonio
van deze codes hou ik, de hersenen bedriegen en dit in native LB.