View object
Represents window where this script is runnung.
view - current view object (of the running script) is accessible through gloabal view variable.
| Constants |
| WINDOW_SHOWN |
Values of view.state property. |
| WINDOW_MINIMIZED |
| WINDOW_MAXIMIZED |
| WINDOW_HIDDEN |
| Properties |
| root |
r - Element, root element of a document loaded into the view. |
| state |
r/w - state of the view's window. Applicable only for toplevel frame windows (sciter.exe). |
| focus |
r/w - Element, current element that has input focus. To set new element in focus use view.focus = el; |
| eventsRoot |
r/w - Element, "events root" element. Used for implementation of "modal document loops". If set then all UI events that are targeted to elements that are not descendants of the element will be rerouted to the element. Setting this element may cause current focus element to be changed. Here is typical modal document loop:
view.eventsRoot = dlg;
while (dlg.isVisible) view.doEvent();
dlg.style#display = "none";
view.eventsRoot = null;
|
| Methods |
this |
(non-constructable) |
| load |
(url:string[, now: bool]) : true/false
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. |
| load |
(stream:Stream) : true/false
Method loads new document (replaces current one) in the current view from the given in-memory stream. |
| box |
( part [, edge [, relativeTo ]] ) returns: integer, device pixels
Returns coordinates of the edges of the view. Parameters:
- part - one of symbolic constants #left, #top, #right, #bottom, #width or #height. Defines part of box (rectangle) to return.
- edge, one of view:
- #border - border box edge - OS window border bounds,
- #client - client area edge,
- relativeTo, one of:
- #screen - returns coordinate relative to the origin of the screen,
- #self, default value - all coordinates are relative to the origin of the client area of the view.
|
| move |
( x:int, y:int [, width:int, height:int] ) :void
Replaces window of the view (dialog or frame) on the screen. This method is applicable only for standalone Sciter. |
| selectFile |
( #save | #load, filter:string , ext: string ) : string | null
Methods shows system file selector modal dialog and returns full path name of the selected file or null if user cancels this dialog.
- First parameter is either #save or #load symbol. If #save is provided then dialog will have a caption Save As... otherwise (#load) it will have caption Open...
- filter is a string - filter which defines list of allowed file extensions seprated by character '|' in the form: "label1|file.ext1|label2|file.ext1|.." where label is a label of item (appears in the selector on the dialog) and file.ext is a ';' seprated list of filename templates.
- ext is a string - default file extension used if user will type filename without extension.
Following sample will popup dialog to select html files and will load file in current view:
var fn = view.selectFile(#open, "HTML Files (*.htm,*.html)|*.HTM;*.HTML|All Files (*.*)|*.*" , "html" );
if( fn ) view.load(fn); |
| selectPrinter |
TBD |
| dialog |
( url: string | stream: Stream [, parameters: any [, position: int = 5] ] ) : undefined | value passed to close method.
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.
position is an integer in range [1..9], it defines position of the dialog window relative to the parent view window. For meaning of the values see NUMPAD on the keyboard, e.g. position 5 means center/middle of the dialog will be placed in the center/middle of the view. |
| msgbox |
( type:symbol, text: string, [ title: string, [ buttons [, onClose: function [, onLoad: function ]]]] ) : undefined | symbol of the button pressed to close dialog.
- type - symbol, one of the following values: #alert, #information, #question or #warning ;
- text - string, either plain text or html ;
- title - string, caption of the dialog window;
- buttons - button definition(s), either:
- one of the symbols: #ok, #cancel, #abort, #ignore, #yes, #no or #close, or
- object with the structure { id:#somesymbol, text:"Some Text" } or
- array of symbols or objects above;
- onClose - function with the signature function(id, root) 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.
- onLoad - function with the signature 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.
Samples:
- 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"} ] );
|
| close |
( [retval: any] ) : undefined
closes current view (or dialog if it is view of dialog window). retval is any scripting object - return value of the dialog() function. |
| doEvent |
( [#wait | #nowait | #all] ) : undefined
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:
- #wait - waits for the next event in the UI message queue, default behavior.
- #nowait - if there is any event in message queue handles it and returns immediately if there no any messages;
- #all - executes all pending messeages in the message queue. Returns immediately if there no any messages;
|
|