Skip to content

Window Frame Objects and Events

sihorton edited this page Nov 19, 2012 · 1 revision

Window Creation Options

Most of these options are adjustable after window creation. They are all optional with the defaults shown below.

  • width = 640
  • height = 460
  • left = centered
  • top = centered
  • name = auto-generated, it's only used to identify the window on app.windows
  • url = 'http://appjs' - serve static file root and routers
  • autoResize = false - resizes in response to html content
  • showChrome = true - show border and title bar
  • resizable = false - control if users can resize window
  • disableSecurity = true - allow cross origin requests
  • opacity = 1 - flat percent opacity for window
  • alpha = false - per-pixel alpha blended (Win & Mac)
  • fullscreen = false - client area covers whole screen
  • icons = {} - window icon in tray/taskbar/titlebar

Window

Window objects are created and returned by app.createWindow. A window object will itself be the global object of the browser contect once the page has loaded. If the page loads a new url the same window object will morph to the uninitialized state and then become the new browser global when it is ready.

Window Events

  • window.on('create') - window has been created and is ready for the first time
  • window.on('ready') - window context is ready to use, including browser global
  • window.on('close') - window has been closed entirely and has ceased to exist
  • window.on('minimize') - window was just minimized
  • window.on('maximize') - window was just maximized
  • window.on('fullscreen') - window was just fullscreened
  • window.on('restore') - window was just restored
  • window.on('move') - window was just moveed
  • window.on('resize') - window was just resized

Frame

Most of the controls to control the browser container are found on window.frame. window.frame is always available, whether the browser's global context is current initialized or not.

Frame Properties

  • window.frame.left - integer
  • window.frame.top - integer
  • window.frame.width - integer
  • window.frame.height - integer
  • window.frame.opacity - float between 0 and 1
  • window.frame.title - string
  • window.frame.state - one of ['normal', 'maximized', 'minimized', 'fullscreen']
  • window.frame.resizable - boolean
  • window.frame.autoResize - boolean
  • window.frame.showChrome - boolean
  • window.frame.alpha - boolean
  • window.frame.topmost - boolean

Frame Methods

  • window.frame.fullscreen()
  • window.frame.minimize()
  • window.frame.maximize()
  • window.frame.restore()
  • window.frame.center()
  • window.frame.show()
  • window.frame.hide()
  • window.frame.resize(width, height)
  • window.frame.move(left, top, [width], [height])
  • window.frame.fade(toOpacity, milliseconds, callback)
  • window.frame.drag() - (Windows only currently)
  • window.frame.openDevTools()
  • window.frame.closeDevTools()