简体   繁体   中英

How do I use the IUP THEME attribute/DEFAULTTHEME global attribute

IUP 3.26 introduced a THEME attribute:

THEME common attribute and DEFAULTTHEME global attribute that works for all controls to apply a set of attributes at once.

I'm using IUP 3.28 and have followed (I think) the documentation to standardise the appearance of various controls; however, it isn't working as I expect -- in fact it doesn't seem to be working at all. The attributes specified in the Theme for each control aren't being applied, so there's clearly something I have misunderstood. In the example the button should have pink text, but it doesn't.

      require "iuplua"
      iup.SetGlobal("DLGBGCOLOR","255 255 255") --default background colour
      iup.SetGlobal("TXTBGCOLOR", "255,255,255") --default text color
    
      myButtonTheme = iup.user{alignment="ALEFT:ACENTER", expand = "HORIZONTAL",
        padding = "20x10", fgcolor = "255 0 255"}
    
      myTheme = iup.user{
        IUPBUTTON = myButtonTheme
      }
    
      iup.SetGlobal("DEFAULTTHEME", "myTheme") --default settings for iup controls
      b = iup.button{title = "This should be pink"}
      dlg = iup.dialog{iup.hbox{b}}
      dlg:show()
      iup.MainLoop()
      dlg:destroy()

ETA: If I create the button thus: b = iup.button{title = "This should be pink", theme = myButtonTheme} it works; but if I rely on DEFAULTHEME it doesn't. I have some buttons created by libraries that I want to theme consistently

It is missing the call:

 iup.SetHandle("myTheme", myTheme)

After creating the Lua myTheme control.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM