how to use my own image as a button?
Author |
Message |
sakurasan1122
|
Posted: Tue Jan 08, 2008 4:05 pm Post subject: how to use my own image as a button? |
|
|
so lets say i made a button in photoshop or something. Instead of using those grey turing buttons, how could i use my image as the button? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Tue Jan 08, 2008 4:37 pm Post subject: RE:how to use my own image as a button? |
|
|
this depends on what kind of functionality you want our of your button. Does it have to act as the rest of GUI module, or is this stand-alone? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
sakurasan1122
|
Posted: Tue Jan 08, 2008 4:42 pm Post subject: RE:how to use my own image as a button? |
|
|
Well the buttons just going to have its own process, i already had the code but that only makes the plain grey button and i want to use my own image as a button |
|
|
|
|
![](images/spacer.gif) |
Nick
![](http://compsci.ca/v3/uploads/user_avatars/19644337547e837b41d67a.png)
|
Posted: Tue Jan 08, 2008 4:51 pm Post subject: RE:how to use my own image as a button? |
|
|
well yoou can
a:use turing's GUI the syntax is
GUI.CreatePicture ( x, y, picture : int, mergePic : boolean ) : int
or
b: create your own button with
Pic.Draw
and
Mouse.Where |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Tue Jan 08, 2008 5:03 pm Post subject: RE:how to use my own image as a button? |
|
|
GUI.CreatePicture doesn't respond to clicks, but if you overlay the picture over your grey button, the latter might still trigger.
If you have just one button, Mouse.Where is simpler than having to deal with the GUI module. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
sakurasan1122
|
Posted: Tue Jan 08, 2008 5:05 pm Post subject: Re: how to use my own image as a button? |
|
|
lets say i have a .jpg image that i want to be my button, how would i code that?
currently im using something like this:
i still want the button to perform a process though
Turing: | import GUI
procedure hello
locate(1, 1)
put "Hello User, you have clicked Button #1!"
end hello
procedure hi
locate(1, 1)
put "Hello User, you have clicked Button #2!!"
end hi
var button1: int:= GUI.CreateButton(25, 25, 0, "Button 1",hello )
var button2: int:= GUI.CreateButton(25, 50, 0, "button 2",hi )
loop
exit when GUI.ProcessEvent
end loop |
|
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Tue Jan 08, 2008 7:59 pm Post subject: RE:how to use my own image as a button? |
|
|
instead of the exit when GUI.ProcessEvent loop, you have one with Mouse.Where that checks if the mouse has been clicked and it's located over your image. If the conditions are met, you call the procedure.
If you want to have two buttons, you would need two such if statements.
The GUI module does all of that, and abstracts it away from your view, but as a result it is very inflexible. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
|
|