Page 3 of 13

Re: Geyser UI Template

Posted: Fri Sep 27, 2013 1:21 am
by icesteruk
Code: [show] | [select all] lua
GUI.BashingIcon = Geyser.Label:new({
  name = "GUI.BashingIcon",
  width = "80%",
  height = "80%",
},GUI.Icon1)
GUI.BashingIconCSS = CSSMan.new([[
  margin: 2px;
  border-image: url("]]..getMudletHomeDir():gsub("\\","/")..[[/images/alertness.png");
]])


GUI.BashingIcon:setStyleSheet(GUI.BashingIconCSS:getCSS())

How would you make that into a clickable, as

setLabelCallBack("GUI.BashingIconCss", "namehere") and
setLabelCallBack("GUI.BashingIcon", "namehere") Give errors and dont work :/

Sorry for all the questions

Re: Geyser UI Template

Posted: Fri Sep 27, 2013 1:30 am
by Jor'Mox
setLabelClickCallback takes a function name, and a list of arguments, like this:

setLabelClickCallback("myLabel","send","hello")

Re: Geyser UI Template

Posted: Fri Sep 27, 2013 4:42 pm
by icesteruk
that doesn't work either.. I'll read up on the manuals. Thanks

Re: Geyser UI Template

Posted: Fri Sep 27, 2013 4:55 pm
by Akaya
Code: [show] | [select all] lua
GUI.BashingIcon:setClickCallback("GUI.Clicky","You clicked me!")

function GUI.Clicky(arg)
  echo(arg)
end
That should echo You clicked me! when GUI.BashingIcon is clicked though the way Jor'Mox mentioned should work just fine. This is the OO way via Geyser.

Re: Geyser UI Template

Posted: Fri Sep 27, 2013 5:07 pm
by icesteruk
Akaya wrote:
Code: [show] | [select all] lua
GUI.BashingIcon:setClickCallback("GUI.Clicky","You clicked me!")

function GUI.Clicky(arg)
  echo(arg)
end
That should echo You clicked me! when GUI.BashingIcon is clicked though the way Jor'Mox mentioned should work just fine. This is the OO way via Geyser.

Nope I been doing it that way, I think its having isssues with letting me click the 'image' so I had to do it this way

setLabelClickCallback("GUI.Icon1", "on_bash_press")
GUI.Icon1:echo("<b><center>Bashing")

and use the 'Bashing' text to be clickable

Re: Geyser UI Template

Posted: Fri Sep 27, 2013 5:24 pm
by Akaya
Clicking images shouldn't be an issue... http://wiki.mudlet.org/w/Manual:Geyser#Clickable_images

*There's a note in that link that mentions you not being able to include callback functions in a table but I think its outdated info and you actually CAN include them in a table.

Re: Geyser UI Template

Posted: Fri Sep 27, 2013 9:23 pm
by Vadi
Yeah, it seems they work now (along with event handlers in tables).

Re: Geyser UI Template

Posted: Fri Sep 27, 2013 10:44 pm
by Jor'Mox
Event handlers working with function in tables made my life so much easier. Though, I still don't understand the motivation for the regular event registering system. Why would I want my script to depend on what it is called in order to function?

Re: Geyser UI Template

Posted: Fri Sep 27, 2013 11:01 pm
by Vadi
What do you mean exactly? I didn't quite understand.

Re: Geyser UI Template

Posted: Fri Sep 27, 2013 11:09 pm
by Jor'Mox
I seem to remember it stating that you listed the events in the "Add User Defined Event Handler" box at the top of a script, and when those events fired, they were handled by a function with the same name as the script.
Registering an event handler via UI

Registering an event handler means that you’ll be telling Mudlet what function should it call for you when an event is raised, so it’s a two step process - you need to tell it both what function you’d like to be called, and on what event should it be called.

To tell it what function should be called, create a new script, and give the script the name of the function you’d like to be called. This is the only time where an items name matters in Mudlet. You can define the function right inside the script as well, if you’d like.

Next, we tell it what event or events should this function be called on - you can add multiple ones. To do that, enter the events name in the Add User Defined Event Handler: field, press enter, and it’ll go into the list - and that is all.