HTML Window

Sciter allows to create so called HTML windows and dialogs – check view.window() and view.dialog() functions.
While creating such windows you supply their content as HTML – either URL of HTML document or literal HTML string.

Provided HTML and CSS defines not only content of the window but it also can define type of window chrome (a.k.a. window’s frame) to use. Examples of different HTML window types:

standard-window window-layered flat-window transparent-window

In order to support window chrome definitions, Sciter was extended by the following HTML attributes:

window-frame attribute

window-frame attribute on root <html> element accepts the following values:

  • “none” or attribute omitted as whole – standard window , standard OS desktop window frame (with caption and close/maximize) buttons.
  • “solid” – frameless window with non-transparent background, just a rectangular box. Window chrome needs to be defined in markup (see below).
  • “solid-with-shadow” same as above but with shadow if OS supports it.
  • “extended” – window that allows to replace custom elements in window’s caption bar.
  • “transparent” – layered window, it’s shape is determined by background image or border-radius. CSS shall define html { background-color:transparent } for it.

See samples in sdk/samples/dialogs+windows/ folder.

window-resizable attribute

window-resizable attribute on root <html> element will make the window resizeable (e.g. WS_THICKFRAME on Windows).

view.windowMinSize() and view.windowMaxSize() methods allow to establish limits on window size.

window-blurbehind attribute

This attribute allows to create windows with blur-behind effect (note left side-bar):


window-blurbehind attribute accepts the following values:

  • "auto" – default OS blur-behind effect;
  • "ultra-dark", "dark", "light" and "ultra-light" – different level of ambient filter, screenshot above was made with window-blurbehind="dark".

Note: in order to see content of desktop through the window surface html (root element) shall have background-color:transparent defined on it.

window-icon="...url..." attribute

This attribute allows to define window icon – image that OS will use in window decoration and when the window is collapsed to taskbar.

Window chrome elements:

Some elements on custom window frames may have role attribute defined with the following values:

  • role=window-close – close button
  • role=window-icon – window icon button
  • role=window-minimize – minimize button
  • role=window-maximize – maximize/restore button
  • role=window-caption – window caption element – user can drag the window by pressing mouse in it.
  • role=window-body or <body> – area (four bands) between <html> and that body element is used for window resizing.

Existence of such elements determines WS_NCHITTEST handling on Windows.

Windows and desktop in script

Here is the list of methods and properties that are available for script to define and manipulate the window:

  • view.windowState – property allows to request and change window state: hidden, shown, maximized, full screen, etc.
  • view.windowCaption – property, caption of the window.
  • view.windowAspectRatio – property, defines width/height ratio of the window.
  • view.windowTopmost – property, instructs the window to appear on top of z-order.
  • view.windowResizable – property, allows the window to be sized by the user.
  • view.windowMaximizable – property, defines if window chrome contains “maximize” button.
  • view.windowMinimizable – property, defines if window chrome contains “minimize” button.
  • view.windowBlurbehind – property, defines level of blur-behind effect.
  • view.windowMinSize and view.windowMaxSize – functions, define boundaries in which window can be resized by the user.
  • view.windowIcon – property, allows to change window icon in run-time. Including script generated images.
  • view.windowMove() – move and size the window programmatically.
  • view.close() – request the window to be closed.

Methods that allow to create windows and dialogs:

  • view.window(params) and View.window(params) – create new owned (dependent) window or independent window (when it is called as a method of the class).
  • view.dialog(params) – create and show modal dialog. The function will wait until user will not close the dialog.
  • view.msgbox(params) – show modal message box.

Desktop/monitors related functions:

  • View.screens – property, reports number of monitors;
  • view.screen – property, reports monitor this window is on at the moment;
  • view.screenBox() – function, allows to get location and dimension of each monitor, its symbolic name or make a screenshot of the screen.

Auxiliary dialogs:

  • view.selectFile(params) ;
  • view.selectFolder(params) ;
  • view.selectPrinter(params) .

@mixin feature in Sciter’s CSS

I am adding @mixin construct to Sciter’s CSS.

The mixin is a named set of CSS properties that can be applied by name to CSS rules. The feature is similar SASS’s mixins (but no parameters yet)

Consider this declaration:

    @mixin LIKE-BUTTON 
      background: linear-gradient(top, #3498db, #2980b9);
      border-radius: 28dip;
      color: #ffffff;
      font-size: 20dip;
      padding: 10dip 20dip 10dip 20dip;
      text-decoration: none;

It declares LIKE-BUTTON block of properties that can be mixed into style rules by LIKE-BUTTON name (prepended by ‘@’)

    div { 

    a {