Represents window where this script is running.
view - current view object (of the running script) is accessible through global view variable.
View.WINDOW_MINIMIZED,
View.WINDOW_MAXIMIZED
, View.WINDOW_HIDDEN
, View.WINDOW_SHOWN
or View.WINDOW_FULL_SCREEN
.view.eventsRoot = dlg; while (dlg.isVisible) view.doEvent(); dlg.style#display = "none"; view.eventsRoot = null;
view.minSize = (160,100);
view.maxSize = (1600,1000);
null
- set default icon, "url"
- string, url of window icon or instance of Image
.#auto
| #ultra-dark
| #dark
| #light
| #ultra-light
| #none
values. If this flag is set then the window window is semitransparent. Root document shall use html { background:transparent; }
in order to see desktop behind the window.#standard
| #extended
| #solid
| #solid-with-shadow
| #transparent
values. After loading the property matches value of window-frame
attribute of its root <html>
document.Method loads new document (replaces current one) in the current view from the given url. If now is equal to true this method loads document synchronously - method will return after document will be downloaded and loaded in the view.
Method loads new document (replaces current one) in the current view from the given in-memory stream.
Returns coordinates of the edges of the view. Parameters:
Returns screen(monitor) projection on cumulative desktop space. Parameters:
Replaces window of the view (dialog or frame) on the screen. This method is applicable only for standalone Sciter.
If clientCoordinates is true x and y are interpretted as a desired position of the client area on the screen.
Replaces window and changes dimension of the view (dialog or frame) on the screen. This method is applicable only for standalone Sciter.
If clientCoordinates is true x,y, width and height are interpreted as a desired position/size of the client area on the screen.
Returns or sets value of particular media variable.
If no newVars parameter provided then the method returns current set of media variables used by the view.
If newVars is an object then the method will update view's media variables from properties of the object. Returns undefined in this case.
The method can be called as for particular view (window) as view.mediaVars(newVars)
or as a class method View.mediaVars(newVars)
. In later case it will set default media variables for all windows created after the call.
Methods shows system file selector modal dialog and returns full path name of the selected file or null if user cancels this dialog.
var fn = view.selectFile(#open, "HTML Files (*.htm,*.html)|*.HTM;*.HTML|All Files (*.*)|*.*" , "html" ); if( fn ) view.load(fn);
Methods shows system folder selector modal dialog and returns full path name of the selected folder or null if user cancels this dialog.
Shows modal dialog defined by document at url or contained in in-memory stream. В object parameters if given will be copied to view.parameters variable available for scripts inside dialog HTML.
alignment - integer, 1..9 - alignment of the window relative to the screen, -1 .. -9 - relative to its parent window, For meaning of the values see NUMPAD on the keyboard, e.g. alignment 5 means center/middle of the dialog will be placed in the center/middle of the screen.
Another form of calling modal dialog using single parameter object.
If x,y and alignment provided then x,y defines reference point and the alignment defines relative position of the window against that point.
function(root, id)
returning true|false. This function will be called on attempt to close dialog with parameters id - id of the button pressed and root - root node of the HTML document of the dialog. Function shall return true if dialog can be closed at the moment.function(root)
. This function will be called after creating dialog window. Use it if you need to do some initialization, e.g. fill data of input fields if text is an html containing <input>s.view.msgbox(#information, "I am fine!");
- will show simple message;view.msgbox(#question, "Be or not to be?", "Huh?",
[ {id:#yes, text:"To be"}, {id:#no, text:"Not to be"} ] );
Creates separate window.
If x,y and alignment provided then x,y defines reference point and the alignment defines relative position of the window against that point.
To open window in detached mode ( it will stay on screen even when its owner window is collapsed ) call the method as static one - using View
class rather than view
instance: View.window(...)
.
closes current view (or dialog if it is view of dialog window). retval is any scripting object - return value of the dialog() function.
Passes control to the operating system. Control is returned after the operating system has finished processing next event in its event queue. This method is used for implementing modal document loops.
In case of:
Executes all pending changes in the view and renders what was changed on the screen. After this call box coordinates of all DOM elements are valid.
Use this method when you need to commit all updates made on the DOM to the moment. For example:
function retrieveDataFromDB(recordSet) { while(!recordSet.EOF()) { grid.appendRow(recordSet.row); if(++numRowsAdded > 10) { numRowsAdded = 0; view.update(); } } }
Calls the callback function for each format of data presented in system clipboard at the moment. The callback function has following signature: function (
dataType
: symbol ) {...}
, where dataType is a symbol designating one of supported formats:
{ url: string , caption: string }
;Fetches data from the clipboard in format defined by the dataType parameter. For list of allowed values see previous method definition.
Note: for the #html format this function returns two values: source URL (if any) and html data per se.
To get both of them use this : var (url, html) = view.clipboard(#get, #html);
Stores data to the clipboard. When data is an object then it is expected that it has the following structure where all properties are optional except any one:
{ text: "some text", html: "<b>some html</b>", link: { caption: "some text", url: "file://some ..." }, file: [ "path1", "path2", ...], json: someData }
Please note that json clipboard format is Sciter specific. You can use it to pass data between Sciter applications.
You can set multiple data items at once (e.g. text and html together). Destination application will pick up format it understands in particular context.
The method returns next/previous/first/last focusable element in TAB order, either from element or from current element in focus.
Performs system drag and drop operation.
element is a DOM element that is used as a drag image, alternatively you can provide image and x/y icon offset as a drag image.
data is an object that contain following properties:
{text: String}
- plain text string;{html: String | Element}
- html, either as a string or outer HTML of given element;{file: String | [String, String, ...]}
- single file name or list of file names to drop;{link: String | { caption: "some text", url: "file://some ..." }}
- single url as a string or caption/url pair;{json: value}
- any value that will be serialized into JSON string. JSON can be used to pass additional data between Sciter windows.The data object may contain multiple properties, destination will choose most appropriate.
ddMode defines types of drag-n-drop operations allowed:
performDrag()
is a blocking operation - the function returns when drag-n-drop is complete or rejected.
Returns cursor location relative to client area of the view:var (x,y) = view.cursorLocation();
Attaches the handler to one of view (window) related events.
nameandns - string that contains one of the event names at the bottom and optionally arbitrary namespace name in the form "name.namespace".
Detaches event handler either by name or by function itself.
eventname here is either "name", full "name.namepsace" or just ".namepsace". Example:
view.off(".mymodule");
will unsubscribe both event handlers set by the code:
view.on("move.mymodule",foo) .on("size.mymodule",foo);
Sends HTTP request with params object having following fields:
Sample: sdk/samples/communication/file-download.htm and sdk/samples/communication/http.tis
Defines parameters of tray icon for the window. Accepts following parameters:
view.trayIcon { image: Image, text: string } : boolean
creates tray icon for the window, parameters:view.trayIcon( #place ) : (x,y,w,h)
- returns location of the tray icon in screen coordinates.view.trayIcon( #remove ) : boolean
- removes tray icon from system status bar.When tray icon is created the view will start receiving trayicon-click events.
Sample: sdk/samples/trayicon
Creates Audio object that allows to play .mp3, .flac and .wav sounds
rq.fulfill()
to provide data for the request;To subscribe to view events use view.on(eventname, handler)
method of the view object providing:
function(sizingParams)
where sizingParams
is an object of this structure: { x:integer, y:integer, width:integer, height: integer, side: 1...9 }
- proposed dimensions of the window and side
is a window side/corner dragged to change window dimension.function(movingParams)
where movingParams
is an object of this structure: { x:integer, y:integer, width:integer, height: integer }
- proposed dimensions of the window. Function-handler can change properties of the object discriminating window movements.var ppi = (1in).toFloat(#px);
and to get pixels-per-dip: var ppdip = (1dip).toFloat(#px);
{ x: integer, y: integer, button: integer }
where x/y are mouse screen coordinates, and button is 1 - left mouse button or 2 - right mouse button or 0 if system does not support right clicks (MacOS) on tray buttons.