• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

setting anchors on a Lua file

Eventide

Member
Joined
Sep 16, 2008
Messages
79
Reaction score
6
Location
Brasil
I'm creating an widget on a lua file, like this:
Code:
tmpLabel = g_ui.createWidget('Label', parent)
It works fine, except that i don't know how to set anchors, is there a function for that?
 
In the future if you will need setting anchors in Lua, you can use:
Code:
somePanel:addAnchor(AnchorTop, 'parent', AnchorTop)
You can use parent, prev, next(?) and none.
 
Ok, solved the issue by creating a widget style...
Hey Eventide, can you tell me how you created an Widget style?
I am trying to change a Panel anchors but apparently 'addAnchor' just don't work.
 
For example you have something like that:
Code:
local button = g_ui.createWidget('HotkeyButton', spellsPanel)

Then in your otui file at the beggining declare it:
Code:
HotkeyButton < UIButton
  image-source: /images/ui/item
  size: 34 34
  font: verdana-11px-rounded
  opacity: 0.7
  text-align: bottomLeft
  text-offset: 1 0

  $hover !disabled:
    opacity: 0.8

  $pressed:
    opacity: 1.0
 
For example you have something like that:
Code:
local button = g_ui.createWidget('HotkeyButton', spellsPanel)

Then in your otui file at the beggining declare it:
Code:
HotkeyButton < UIButton
  image-source: /images/ui/item
  size: 34 34
  font: verdana-11px-rounded
  opacity: 0.7
  text-align: bottomLeft
  text-offset: 1 0

  $hover !disabled:
    opacity: 0.8

  $pressed:
    opacity: 1.0

oh right, so if I want to change a button style I just have to call "mybutton:setStyle("HotkeyButton")" ?
Or it would be the other function 'setStyleFromNode'?
 
Back
Top