Skip to content

uiform register legacy

Peter Lewis edited this page Aug 12, 2020 · 3 revisions

uiform-register-legacy registers a new display element using legacy syntax, which is compatible with the function calls used in all modules/ln_glgui widgets.

Parameter Description
name Display element name
draw Function called when element is drawn: (lambda (gui wgt) ...)
input Function called when element is clicked: (lambda (gui wgt type mx my) ... )

All fields other than x, y, w, and h that could be queried during the draw or input functions must be supplied when declaring an instance of the newly registered element. The best practice is to look in the initialization code for the glgui element that you are registering, and supply a value for every field, including those that are normally created by default.

Example

Example 1: Reuse the (glgui-box g x y w h c) widget as a uiform element, and call it. Note that the color argument is NOT optional in this case and will cause a segfault if omitted.

(uiform-register-legacy 'box glgui:box-draw glgui:box-input)
(box color ,Red)

Example 2: Reuse the (glgui-label g x y w h label fnt color . bgcolor) widget as a uiform element and enable copy, paste, and cursor movement. Note that all fields created in (glgui-label) must be supplied, not just label, fnt, and color.

(uiform-register-legacy 'myText glgui:label-draw glgui:label-input)
(myText 
 old-mx #f
 old-my #f
 rounded #f
 font ,ascii_18.fnt
 label "Registered Legacy Label"
 callback #f
 aftercharcb #f 
 onfocuscb #f 
 armed #f
 longpress (#f #f 0)  
 longpress-range 10 
 longpress-duration 0.5 
 longpress-callback ,glgui:label-copypaste-overlay
 copyable? #t
 pastable? #t
 color ,White
 hidden #f
 direction ,GUI_LEFTTORIGHT
 password #f
 enableinput #t 
 focus #f
 focuspos 0
 clearoninput #f
 showstart #f 
 bgcolor #f
 align ,GUI_ALIGNCENTER
 draw-handle  ,glgui:label-draw
 input-handle ,glgui:label-input
 update-handle ,glgui:label-update
)
Clone this wiki locally