Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 how to use my own image as a button?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
sakurasan1122




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
sakurasan1122




PostPosted: 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
Nick




PostPosted: 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
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
sakurasan1122




PostPosted: 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
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: