|  | Controlling the Viewer
 Back to Contents
 
 
 
 First, make sure you have:
 
 (as of June 2020)
 
 
 
                
                    Important:
                    
                        
                            Anytime xandycoordinates (or any pixel measurement) are provided or recived by the viewer, they are scaled to match the height and width
                            specified in theconfig.inifile. The only exception to this rule isviewerSetDragDistance. 
 
 State
                 The static(ish) size and scaling factors of the viewer.
                    
                        viewerGetViewerDensityFactor():viewerGetWidth()×viewerGetViewerDensityFactor()= Thewindow widthin config.iniGet a number to multiply by screen pixels to turn it into viewer pixels.* 
                                
                                    Generaly this is not needed because the viewer scales everything going in and out to match the width and height specified in the config file.
                                viewerGetWidth(): Gets the width of the viewer in pixels*viewerGetWidthInches(): Gets the width of the viewer in inches*viewerGetHeight(): Gets the height of the viewer in pixels*viewerGetTextureInfo(): Get a message about any changes the viewer performed on the images to get them to work on the client's computer.viewerGetStartTime(): Get the time, measured by JavaScript'sDate.nowof when the viewer first loaded. viewerGetUpTime() counts upwards
                            from this point onward.viewerGetVersion(): Get the version of the viewer build. This will probably be a string likev3. This is not a replacement
                            for the version code you give your own code (that code will change a lot more than the viewer code). 
                *This is thrown off if the viewer zooms the page.
             
 
 Input
                 On the fly control of the viewer.
                    
                        viewerSetDragDistance( newDistance ): The drag distance by default scales to the viewer's pixels, if you want to reset it yourself (to conform to inches or something
                            you can reset it here.viewerSetButtonTime( seconds ): State how manysecondsthe button must be held before the slide advances (note that
                            unlike the config setting, you can only input seconds here, no milliseconds).viewerSetScrollLimit( newLimit ): The maximum amount ofscrollallowed per scroll event.
                            Unless different custom values are needed per client it is best to set this in the config file.viewerSetScrollSensitivity( newSensitivity ): The sensitivity of the scroll wheel.
                            Unless different custom values are needed per client it is best to set this in the config file.viewerPipeInput(keyCode, pressType): Direct input the viewer. This is important because browsers don't do the best job giving canvas elements focus.
                                keyCode is a number, you can use the event flag from event.keyCode (which is becomming obsolete, but still fairly well supported), or use
                                    FLAGviewerKeyScrollUporFLAGviewerKeyScrollDown.pressType is a number to tell whether the key was pressed down, or released, use
                                    FLAGviewerKeyPressReleaseorFLAGviewerKeyPressDown.viewerScrollLock( true or false ): disable or enable scrollingviewerClickLock( true or false ): disable or enable clicking. This means eventswindow.viewerListenerClickAddedandwindow.viewerListenerClickRemovedwon't fire, however the last click will still be set, andwindow.viewerListenerInputwill still fire.viewerSetSlide( setIndex, optinal slideIndex): Tell the viewer to show a specific set of slides. Optionally at a specific index.
                            Note:viewerSetSlide(4, 0)=viewerSetSlide(4). Note that this will log ablurevent on the previous image,
                            and afocusevent on the new image, assuming they are not the same. If they are the same, and you use this to scroll to another
                            slide, it will NOT be logged. If you wish for that event to be logged, add a message withviewerLogScrollMessage(index,message)2 
 
 Present Status
                 Current (but changing) status of the viewer.
                    
                        viewerGetLastClick(): Get the last click, see the config file's overwrite last click setting.
                                This is formatted as x,y,slide,timeThis will be 0,0,0,0 if no click occured since the last viewerResetLastClickviewerGetCurrentSlide(): Get the index for the current slide.viewerGetCurrentSet(): Get the index for the current setviewerGetUpTime(): Get the milliseconds the viewer has been active. This is the same timing method
                            used in the viewer's logs. 
 
 Control
                 Resetting.
                    
                        viewerResetLastClick(): Reset the last click, see the config file's overwrite last click setting.viewerResetSize(): Reset the viewer's size if a new value is provided throughwindow.viewerStatsWidth, Otherwise, the viewer will recreate itself
                            with the same size, which is a lot of expense for no gain.2viewerResetScrolls( index ): Reset the scroll log at a specific image'sindexviewerResetClicks( index): Reset the clicks (log, and displayed clicks) at a specific image'sindexviewerResetHighlights( index ): Reset all of the highlights and shapes (both UI and image) at a specific image'sindexviewerResetShaderLog(): Clear the shader log but not the shaders themselves. Shaders can be removed withviewerRemoveShader(name)Creation
                    
                        viewerSimulateClick( index, x, y, slide ): Simulate a click for the image atindex, at the positionx,y,slide.
                            Note that this could add or remove a click (if one was already nearby). 1
                                These clicks are logged.These clicks fire the window.viewerListenerInputevent.These clicks fire the window.viewerListenerClickAddedorwindow.viewerListenerClickRemovedevent.These clicks do not set the click retrieved by viewerGetLastClick().viewerAddHighlight( index, x, y, slide ): Add a highlight marker for the image atindex, at the positionx,y,slide.viewerAddShapeToImage( name, index, x, y, slide ): Add a shape namednamefromshapes.txtto the image atindex, at the positionx,y,slide. Note, these shapes are effected by shaders. 1viewerAddShapeToUI( name, index, x, y, slide ): Add a shape namednamefromshapes.txtto the image atindex, at the positionx,y,slide. Note, these shapes are not effected by shaders. 1Shaders (Windowing)
                    Look in the shader page  for details on the following functions:
 
                        viewerAddCustomShader( name, vertexShader, fragmentShader, optional log )viewerAddWindowingShaderGray( name, level, width, optional log )viewerAddWindowingShaderValue( name, level, width, optional log )viewerAddWindowingShaderGrayFull( name, level, width, optional log )viewerAddWindowingShaderValueFull( name, level, width, optional log )viewerAddWindowingShaderGray16( name, level, width, optional log )viewerSetveShader( name, optional log )viewerRemoveShader( name, optional log ) 
 
 Logging
                 Getting lists of information (and adding to those lists). Look in the controlssection above for functions to reset logs.Get:
                    
                        viewerGetClicksFor( index, separater1, separater2 ): Get a string containing all of the current clicks for the image atindex. The components
                            (eg: x, y, slide, time) of every click are separated byseparater1, and every click is separated byseparater2.
                                This list doesn't contain every click ever performed, any clicks which have been removed are not reported in the log, if you want those, save them
                                    when they trigger viewerListenerClickAddedandviewerListenerClickRemovedA recorded click does not have any sort of typeidentifier.Clicks have 4 components: x, y, slide, time of clickClick Messages have 2 components: message, time of message
                                    
                                        Be aware that messages aren't wrapped in quotes or anything to signify that they are strings. If you put a comma in your message,
                                        and use a comma for a separater, you will have a difficult time parsing your data later.
                                    viewerGetScrollTimesFor( index, separater1, separater2 ): Get a string containing all of the scrolls performed for the image atindex. The components
                            (eg: slide, time, event) of every scroll are separated byseparater1, and every scroll is separated byseparater2.
                                Each scroll can be flagged with 1 of 4 events.
                                    
                                        f: the focus event, happens whenviewerSetSlidenavigates to the image.w: a scroll event, happens when the user scrolls the image with the mouse scroll wheel (but not whenviewerSetSlidemoves to another slide of the image).d: a scroll event, happens when the user scrolls the image by dragging with touch or mouse (but not whenviewerSetSlidemoves to another slide of the image).k: a scroll event, happens when the user scrolls the image with arrow keys or WASD (but not whenviewerSetSlidemoves to another slide of the image).b: the blur event, happens whenviewerSetSlidenavigates away from the image.m: the message event, you inject a message into the scroll log withviewerLogScrollMessage.If the image was never active, the string should be empty.If the image was active, but the user never scrolled, there should at least be a focus event, and depending on your implementation
                                    a blur event.viewerGetShaderLog( separater1, separater2 ): Get a string containing all of the shader changes for the entire viewer (shaders are not
                            constrained to a particular image). The components of every shader change are separated byseparater1, and every shader change
                            is separated byseparater2. More in The shader documentationAdd:
                    
                        viewerLogClickMessage( index, message ): inject amessageinto the click log for the image atindex.viewerLogScrollMessage( index, message ): inject amessageinto the scroll log for the image atindex.viewerLogShaderMessage( message ): inject amessageinto the shader log. 
 
 
 Tutorial Videos
 
 
 
                1 Returns true if the operation was successful, false if failed.
             
                2 Does not perform an action when called, instead an action is queued
                to happen whenever the opportunity arrises (usually after the next render).
             
 
 
 
 
 
 |  |