How to use a custom color gadget (jscolor)

Just starting out? Need help? Post your questions and find answers here.
User avatar
T4r4ntul4
Posts: 132
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:

How to use a custom color gadget (jscolor)

Post by T4r4ntul4 »

Hi all,

I was making a GUI until i realised theres no colorgadget...

My question is: How to use a custom color gadget like jscolor?
link: http://jscolor.com/

My attempts end on nothing.

With a webgadget it works as expected, but how to use it wthout a webgadget so i can use it besides the other spiderbasic gadgets?
And if that works, how to give it a X and Y location?

Code: Select all

Procedure GadgetEvents()
  
  Select EventGadget()
      
    ; ------------------------------
    ;Case 1 ; 

    ; ------------------------------
      
  EndSelect

  
EndProcedure


If OpenWindow(0, 0, 0, 450, 550, "", #PB_Window_Background)

  ; text gadgets
  TextGadget(0, 20, 40, 150, 25, "Color", #PB_Text_VerticalCenter)
  
  ;WebGadget(10, 20, 20, 300, 200, "jscolor.html")
  
  ; how to use this without using a webgadget?
  ! <script src="jscolor.js"></script>
  ! Color: <input class="jscolor" value="ab2567">

  CloseGadgetList()
  
  
  ; ------------------------------------------------------------------------------------------------------
  
  BindEvent(#PB_Event_Gadget, @GadgetEvents())
  
  CompilerIf #PB_Compiler_OS <> #PB_OS_Web
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  CompilerEndIf
EndIf

User avatar
Peter
Posts: 1197
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: How to use a custom color gadget (jscolor)

Post by Peter »

this might be a first step:

Code: Select all

#myWindow = 0
#myStringGadget = 0

Procedure Init(Callback)
  ! require(["https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.0.4/jscolor.min.js"], function() { v_callback(); } );  
EndProcedure

Procedure Main()
  
  OpenWindow(#myWindow, 0, 0, 322, 205, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  StringGadget(#myStringGadget, 10, 10, 300, 20, "")
  
  Protected GID = GadgetID(#myStringGadget)
  
  ! $(v_gid.div).find("input").addClass("jscolor");
  
EndProcedure

Init(@Main())
Greetings ... Peter
User avatar
T4r4ntul4
Posts: 132
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:

Re: How to use a custom color gadget (jscolor)

Post by T4r4ntul4 »

Nice, thnx! That will do.
Post Reply