Jump to content

Color picker


Desaster

Recommended Posts

Quote from resource description.

when "OK" pressed in picker, it triggers a client-side event "onColorPickerOK":

example usage:

  
-- simple editbox 
local edit = guiCreateEdit(0, 0, 0.1, 0.05, "", true) 
  
addEventHandler("onClientGUIDoubleClick", edit, 
function() 
-- adding a handler, so when editbox double-clicked, it'll open a colorpicker window: 
exports.cpicker:openPicker(source, "#FFAA00", "Pick a color for some editbox:") 
end) 
  
-- this will be triggered when "OK" is pressed in colorpicker 
addEventHandler("onColorPickerOK", root, 
function(element, hex, r, g, b) 
-- the following arguments are passed in the event: 
-- element - contains whatever you passed when opened the picker 
-- hex - hex code of picked color (in the form of "#RRGGBB") 
-- r,g,b - r,g,b values of picked color 
-- 
guiSetText(element, hex) -- set the picked hex value to the editbox 
end) 

---

"onColorPickerChange" event:

the same arguments passed to this event as "onColorPickerOK", example usage:

addEventHandler("onColorPickerChange", root, 
function(element, hex, r, g, b) 
-- assuming you've passed the vehicle element when opening colorpicker: 
setVehicleColor(element, r, g, b) 
end) 

Functions:

bool openPicker ( element/string id , color, string title)  

Opens the Color Picker.

Arguments:

Required:

id - element/string/whatever - stuff that will be returned in event for you to know for which element the picker was opened

Optional:

color - optional, if set to hex color, will open picker with that color selected

title - optional, sets picker window title

Return:

true - if picker was created successfully

false - if a picker for that ID is already open.

bool closePicker ( elemnt/string id ) 

Closes the corresponding colorpicker window (same as "Cancel" button)

Arguments:

Required:

id - element/string/whatever

Returns:

true - if picker for supplied ID existed

false - otherwise

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...