Just starting out? Need help? Post your questions and find answers here.
the.weavster
 
Posts: 135
Joined: Sat Mar 01, 2014 3:02 pm

How to style a button?

by the.weavster Tue Feb 13, 2018 12:56 pm

How do you add a custom style to a button?

I've seen this thread but it doesn't work for me and even built in commands like SetGadgetFont() and SetGadgetColor() seem to get ignored :?
User avatar
Peter
 
Posts: 493
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: How to style a button?

by Peter Tue Feb 13, 2018 1:22 pm

Code: Select all
Procedure SetGadgetColorEx(Gadget, ColorType, Color)
 
  Protected GID = GadgetID(Gadget)
 
  Select GadgetType(Gadget)
     
    Case #PB_GadgetType_Button
     
      Select ColorType
         
        Case #PB_Gadget_FrontColor
          ! $(v_gid.div).find(".dijitButtonText").css("color", spider_helper_ColorToHtml(v_color));
         
        Case #PB_Gadget_BackColor
          ! $(v_gid.div).find(".dijitButtonContents").css("background-color", spider_helper_ColorToHtml(v_color));
         
      EndSelect
     
    Default
     
      Debug "Unsupported GadgetType"
     
  EndSelect
 
EndProcedure

#myWindow = 0
#myButton = 0
#myFont   = 0

OpenWindow(#myWindow, 0, 0, 222, 200, "ButtonGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(#myButton, 10, 10, 200, 40, "Standard Button")
LoadFont(#myFont, "Arial", 24)
SetGadgetFont(#myButton, FontID(#myFont))
SetGadgetColorEx(#myButton, #PB_Gadget_BackColor, #Red)
SetGadgetColorEx(#myButton, #PB_Gadget_FrontColor, #Green)


Image

Greetings ... Peter
the.weavster
 
Posts: 135
Joined: Sat Mar 01, 2014 3:02 pm

Re: How to style a button?

by the.weavster Tue Feb 13, 2018 1:41 pm

Thanks, Peter :D
Dirk Geppert
 
Posts: 58
Joined: Fri Sep 22, 2017 7:02 am

Re: How to style a button?

by Dirk Geppert Wed Feb 28, 2018 2:49 pm

Extended SetGadgetColorEx version, also for PanelGadgets.

Code: Select all
Procedure SetGadgetColorEx(Gadget, ColorType, Color)
 
  Protected GID = GadgetID(Gadget)
 
  Select GadgetType(Gadget)
     
    Case #PB_GadgetType_Panel
      Select ColorType
         
        Case #PB_Gadget_TitleFrontColor
          ! $(v_gid.div).find(".dijitTab").css("color", spider_helper_ColorToHtml(v_color));
         
        Case #PB_Gadget_TitleBackColor
          ! $(v_gid.div).find(".dijitTab").css("background-color", spider_helper_ColorToHtml(v_color));
         
        Case #PB_Gadget_BackColor
          ! $(v_gid.div).find(".dijitContentPane").css("background-color", spider_helper_ColorToHtml(v_color));
     
      EndSelect
     
    Case #PB_GadgetType_Button
     
      Select ColorType
         
        Case #PB_Gadget_FrontColor
          ! $(v_gid.div).find(".dijitButtonText").css("color", spider_helper_ColorToHtml(v_color));
         
        Case #PB_Gadget_BackColor
          ! $(v_gid.div).find(".dijitButtonContents").css("background-color", spider_helper_ColorToHtml(v_color));
         
      EndSelect
     
    Default
     
      Debug "Unsupported GadgetType"
     
  EndSelect
 
EndProcedure
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 2 guests