Author Topic: clickable image  (Read 1212 times)

pielago

  • Newcomer
  • *
  • Posts: 13
    • View Profile
clickable image
« on: 04. August 2013, 02:56:41 »
okay guys

I have a picture and i want to make it clickable so once i click it with my mouse it can disiplay a text that says u clicked it..

can someone  give me a way to do it  the pic its 100x100 and its a head of a little cat .so can someone give me a good
example but super basic?? like  putting the mouse on top of the image and click it and than a text appeard saying  (clicked it) right next to it(head)!!

hope you can help me out I been trying to do it and i cant  :(

Tomaaz

  • Guest
Re: clickable image
« Reply #1 on: 05. August 2013, 11:35:39 »
Code: [Select]
openwindow (200, 200, 32, "Test")
im = loadimage("moon.png")
putimage(10, 10, im)
redraw()
x = 0

while 1 do
putimage(10, 10, im)
if mousezone(10, 10, 110, 110) and mouseb() == 1 then
x = x + 1
clearscreen()
putimage(10, 10, im)
drawtext(10, 150, "Clicked "..x.." times")
redraw()
while mouseb() == 1 do
end
end
end

The source and a graphic file are attached.

lelldorin

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
    • BeSly - Knowledge base
Re: clickable image
« Reply #2 on: 06. August 2013, 20:32:55 »
Nice example Tomaaz, but how to end it?

Can i add it into my egsl IDE?

Greetings Lelldorin


pielago

  • Newcomer
  • *
  • Posts: 13
    • View Profile
Re: clickable image
« Reply #3 on: 07. August 2013, 01:42:47 »
Thank you "Tomaaz"
this what I needed  thank you for sharing ....

Tomaaz

  • Guest
Re: clickable image
« Reply #4 on: 15. August 2013, 13:40:47 »
Nice example Tomaaz, but how to end it?

Can i add it into my egsl IDE?

Sure you can add it to your IDE. This is a slightly modified version. You can click 'x' or press 'esc' to close it:

Code: [Select]
openwindow (200, 200, 32, "Test")
im = loadimage("moon.png")
putimage(10, 10, im)
redraw()
x = 0

repeat
putimage(10, 10, im)
if mousezone(10, 10, 110, 110) and mouseb() == 1 then
x = x + 1
clearscreen()
putimage(10, 10, im)
drawtext(10, 150, "Clicked "..x.." times")
redraw()
while mouseb() == 1 do
end
end
k = getkey()
until k == 27 or k == 255