Window
Native window.
Module | require("yue.gui") |
Type | Class |
Inherits | Responder |
Class methods
create(options)
Create a new window with options
.
Parameters
Window::Options
options
Return
Window
Methods
close()
Request to close the window.
hasframe()
Return whether window has a native frame.
Return
boolean
istransparent()
Return whether window is transparent.
Return
boolean
sethasshadow(has)
Set whether window should have shadow.
Depending on platform, this may not work.
Parameters
boolean
has
hasshadow()
Return whether window has shadow.
Return
boolean
setcontentview(view)
Set the content view of the window.
The content view will always be resized to fill window's client area.
Parameters
View
view
getcontentview()
Return the content view of the window.
Return
View
center()
Move the window to the center of the screen.
setcontentsize(size)
Resize window to make the content view fit size
.
Parameters
SizeF
size
getcontentsize()
Return the size of content view.
Return
SizeF
setbounds(bounds)
Change the position and size of the window.
Parameters
RectF
bounds
getbounds()
Return the position and size of the window.
Return
RectF
setsizeconstraints(minsize, maxsize)
Set the minimum and maximum sizes of the window.
Passing an empty size means no constraint.
Parameters
getsizeconstraints()
Return minimum and maximum sizes of the window.
Return
SizeF, SizeF
setcontentsizeconstraints(minsize, maxsize)
Set the minimum and maximum content sizes of the window.
Passing an empty size means no constraint.
Parameters
getcontentsizeconstraints()
Return minimum and maximum content sizes of the window.
Return
SizeF, SizeF
activate()
Show the window and activate it.
deactivate()
Move the focus away from the window.
isactive()
Return whether window has focus.
Return
boolean
setvisible(visible)
Show/hide the window.
Parameters
boolean
visible
isvisible()
Return whether window is visible.
Return
boolean
setalwaysontop(top)
Make the window always show above other normal windows.
Parameters
boolean
top
isalwaysontop()
Return whether window is always above other normal windows.
Return
boolean
setfullscreen(fullscreen)
Enter/leave fullscreen state.
Parameters
boolean
fullscreen
isfullscreen()
Return whether window is in fullscreen.
Return
boolean
maximize()
Maximize the window.
unmaximize()
Unmaximize the window.
ismaximized()
Return whether window is maximized.
Return
boolean
minimize()
Minimize the window.
restore()
Restore the minimized window.
isminimized()
Return whether window is minimized.
Return
boolean
setresizable(resizable)
Set whether window can be resized.
Parameters
boolean
resizable
isresizable()
Return whether window can be resized.
Return
boolean
setmaximizable(maximizable)
Set whether window can be maximize.
Parameters
boolean
maximizable
ismaximizable()
Return whether window can be maximize.
Return
boolean
setminimizable(minimizable)
Set whether window can be minimized.
Parameters
boolean
minimizable
isminimizable()
Return whether window can be minimized.
Return
boolean
setmovable(movable)
Set whether window can be moved.
Parameters
boolean
movable
ismovable()
Return whether window can be moved.
Return
boolean
settitle(title)
Set window title.
Parameters
string
title
gettitle()
Get window title.
Return
string
setbackgroundcolor(color)
Set the background color of the window.
Parameters
Color
color
getscalefactor()
Return the scale factor of the window.
Return
number
macOS
settoolbar(toolbar)Set the window toolbar.
Parameters
Toolbar
toolbar
macOS
gettoolbar()Return the window toolbar.
Return
Toolbar
macOS
settitlevisible(visible)Set whether the title is visible, when title was hidden the toolber would be moved into the area previously occupied by the title.
Parameters
boolean
visible
macOS
istitlevisible()Return whether title is visible.
Return
boolean
macOS
setfullsizecontentview(full)Set the NSWindowStyleMaskFullSizeContentView
style on the window.
Parameters
boolean
full
macOS
isfullsizecontentview()Return whether the window has NSWindowStyleMaskFullSizeContentView
style.
Return
boolean
Windows Linux
setskiptaskbar(skip)Set whether to hide the window from taskbar.
Parameters
boolean
skip
Windows Linux
seticon(icon)Set the window icon.
Parameters
Image
icon
Windows Linux
setmenubar(menubar)Set the window menu bar.
Parameters
MenuBar
menubar
Windows Linux
getmenubar()Return the window menu bar.
Return
MenuBar
Windows Linux
setmenubarvisible(visible)Set whether the window menu bar is visible.
The accelerators of menu items will still work when menu bar is hidden.
Calling setmenu
will reset the menu bar to visible.
Parameters
boolean
visible
Windows
gethwnd()Return a light userdata representing the HWND of the native window.
To get the value of HWND, you should directly convert the light userdata to HWND, instead of reading the memory of the light userdata.
Return
userdata
getparentwindow()
Return the parent window.
Return
Window
addchildwindow(child)
Make child
a child window of this window.
This method will do nothing if child
already has a parent window.
Parameters
Window
child
removechildwindow(child)
Remove this window as child
's parent window.
Parameters
Window
child
getchildwindows()
Return all the child windows of this window.
Return
table
Events
onclose(self)
Emitted when the window is closed.
Parameters
Window
self
Preventable
No.onfocus(self)
Emitted when the window is focused.
Parameters
Window
self
Preventable
No.onblur(self)
Emitted when the window lost focus.
Parameters
Window
self
Preventable
No.Delegates
shouldclose(self)
Called when user requests to close the window, should return whether the window can be closed.
Parameters
Window
self
Return
boolean