Page 1 of 2

Double click on a picture

Posted: Sat Jun 24, 2023 7:57 pm
by papiosaur
Hello,

is it possible to double click on a brush inserted between <rectangle/> to do an action please ?

I have tried many thing but nothing work...

Thanks for your help.

Re: Double click on a picture

Posted: Sat Jun 24, 2023 8:57 pm
by plouf
have you try to display it using Button.Icon (aka do it buton) or inside a html class ?

both these classes provide events

Re: Double click on a picture

Posted: Sun Jun 25, 2023 6:03 pm
by papiosaur
Thanks plouf!

I will try them and comeback here

Re: Double click on a picture

Posted: Mon Jun 26, 2023 6:18 pm
by papiosaur
Hello plouf,

i have tried the 2 solutions but without success...

Re: Double click on a picture

Posted: Mon Jun 26, 2023 9:58 pm
by papiosaur
ok, seems work ok with Button.Icon :-)

Thanks a lot plouf!

Re: Double click on a picture

Posted: Tue Jun 27, 2023 10:59 am
by papiosaur
Is it possible to change the picture of the button with moai.Set() ?

I try but don't work...

work with picture class...

Re: Double click on a picture

Posted: Tue Jun 27, 2023 11:34 am
by papiosaur
ok solved with LoadBrush()

Re: Double click on a picture

Posted: Tue Jun 27, 2023 3:13 pm
by papiosaur
sorry, doesn't work, i can't update the brush in the button...

Any ideas please?

Re: Double click on a picture

Posted: Thu Jun 29, 2023 9:26 pm
by airsoftsoftwair
papiosaur wrote: Tue Jun 27, 2023 3:13 pm sorry, doesn't work, i can't update the brush in the button...

Any ideas please?
Button.Icon has an applicability of I so moai.Set() won't work. The problem could be circumvented by detaching, re-creating and re-attaching the button but that is a rather ugly solution and will probably cause a visible visual glitch to the GUI.

To come back to your original problem: I agree that RapaGUI's Image class should provide some event handlers like mouse clicks. I'll add this for the next update. It has already been requested here.

Re: Double click on a picture

Posted: Fri Jun 30, 2023 7:13 pm
by plouf
best way is to wait Adnreas to implement it, in the mean time you can use HOllywood display as a workaround
here is an example with single click

Code: Select all

xml$ = [[
<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
					
	<window id="win" title="Tasks"  >
		<vgroup>
		<rectangle />
		<button id="ok">OK</button>

			<hollywood display="2" width="150" height="150"/>
		<button id="no">NO</button>


		</vgroup>
	</window>
</application>
]]

@REQUIRE "RapaGUI"

CreateDisplay(2,{color=#RED,x=150,y=150})
SelectDisplay(2)
CreateBrush(1,15,15,#GREEN)
CreateBrush(0,30,30,#BLUE)
DisplayBrush(1,20,20)


moai.CreateApp(xml$)
Function MouseUp(msg)
	DebugPrint("clicl")
	DisplayBrush(brush,20,20)
	brush = 1-brush
EndFunction


InstallEventHandler({RapaGUI = p_eventFunc,OnMouseUp=MouseUp})

Repeat
	WaitEvent
Forever