Geyser UI Template

Share your scripts and packages with other Mudlet users.
icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Geyser UI Template

Post 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

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Geyser UI Template

Post by Jor'Mox »

setLabelClickCallback takes a function name, and a list of arguments, like this:

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

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Geyser UI Template

Post by icesteruk »

that doesn't work either.. I'll read up on the manuals. Thanks

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Geyser UI Template

Post 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.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Geyser UI Template

Post 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

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Geyser UI Template

Post 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.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Geyser UI Template

Post by Vadi »

Yeah, it seems they work now (along with event handlers in tables).

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Geyser UI Template

Post 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?

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Geyser UI Template

Post by Vadi »

What do you mean exactly? I didn't quite understand.

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Geyser UI Template

Post 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.

Post Reply