Skip to content
Jonathan Chan edited this page Jun 12, 2018 · 7 revisions

glgui-label create a Label widget from a string

Parameter Description
g The Graphical User Interface (GUI) belonging to this widget
x The lower left corner along the x-axis in pixels
y The lower left corner along the y-axis in pixels
w The width of the element in pixels
h The height of the element in pixels
label The string for label
fnt The font used to render the label string
color The widget color
bgcolor Optional: The widget background color

Attributes

Besides the parameters set in the procedure, the widget has the following attributes that can be set using glgui-widget-set!:

Attribute Default Value Description
rounded False If true, the background rectangle has rounded corners.
aftercharcb False If set to a procedure and focus is true, then the procedure is called after each character is typed or deleted.
onfocuscb False If set to a procedure and focus is false, then the procedure is called upon first click on the label.
hidden False If true, the widget is not displayed.
direction GUI_LEFTTORIGHT If set to GUI_RIGHTTOLEFT then text is wrapped with the right end of the string on the top line and the left end on the bottom line.
password False If true, each character in the label is rendered as an *.
enableinput False If true, clicking on the label will set focus to true.
focus False If true, key events such as EVENT_KEYRELEASE and EVENT_KEYBACKSPACE change the contents of the label.
clearoninput False If true and focus is true, the next character entered while will replace the entire contents of the label and clearoninput will be set to false.
showstart False This controls which end of a label's text is visible if the content is too long for the dimensions. If true and align is GUI_ALIGNCENTER the label will show the start of the text instead of the end. If true, align is GUI_ALIGNLEFT, and focus is true, the label will show the start of the text instead of the end.
align GUI_ALIGNLEFT This controls the alignment of the text within the horizontal dimensions of the label. If set to GUI_ALIGNCENTER, the text is centered and if set to GUI_ALIGNRIGHT the text is aligned to the right.
longpress-range 10 The farthest you can move in pixels from where you pressed down before a longpress event is cancelled.
longpress-duration 0.5 The duration you have to hold for in seconds to trigger a longpress event.
longpress-callback glgui:label-copypaste-overlay Callback for longpress events. By default, it brings up the copy/paste menu when copyable? or pastable? is enabled.
copyable? False If true, longpressing on a label will bring up a menu with a copy button that allows you to copy the text in the label to the system clipboard.
pastable? False If true, longpressing on a label will bring up a menu with a paste button that allows you to paste text currently in the system clipboard (if any) into the label at position focuspos.

Example

Example1: Create a cyan colored label that says "100". The widget should have the following specification x=10, x=25, w=40, h=60. It requires a numerics font libary in size 64 to work.

(glgui-label mygui 10 25 40 60 "100" num64.fnt Cyan)

Example2: Create a label "aaaa", which when clicked displays the event type EVENT_BUTTON1UP on the console.

(set! lbl (glgui-inputlabel gui bx by bw bh "aaaa" ascii_18.fnt Red)))
(glgui-widget-set! gui lbl 'onfocuscb (lambda (g wgt type mx my) (display type) (newline)))
Clone this wiki locally