adjusting documentation for the view predicates
This commit is contained in:
parent
2cc5ab5c28
commit
eacc559bf1
30
js-assembler/runtime-src/baselib-srclocs.js
Normal file
30
js-assembler/runtime-src/baselib-srclocs.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
(function(baselib) {
|
||||
'use strict';
|
||||
|
||||
var exports = {};
|
||||
baselib.srclocs = exports;
|
||||
|
||||
|
||||
// (define-struct srcloc (source line column position span))
|
||||
var srcloc = baselib.structs.makeStructureType(
|
||||
'srcloc', false, 5, 0, false, false);
|
||||
|
||||
|
||||
var makeSrcloc = srcloc.constructor;
|
||||
|
||||
var isSrcloc = srcloc.predicate;
|
||||
var srclocSource = function(x) { return srcloc.accessor(x, 0); }
|
||||
var srclocLine = function(x) { return srcloc.accessor(x, 1); }
|
||||
var srclocColumn = function(x) { return srcloc.accessor(x, 2); }
|
||||
var srclocPosition = function(x) { return srcloc.accessor(x, 3); }
|
||||
var srclocSpan = function(x) { return srcloc.accessor(x, 4); }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
exports.makeSrcloc = makeSrcloc;
|
||||
exports.isSrcloc = isSrcloc;
|
||||
exports.srclocSource = srclocSource;
|
||||
exports.srclocColumn = srclocColumn;
|
||||
exports.srclocPosition = srclocPosition;
|
||||
exports.srclocSpan = srclocSpan;
|
||||
|
||||
}(this.plt.baselib))
|
|
@ -357,32 +357,55 @@ moment.
|
|||
}
|
||||
|
||||
|
||||
Once we have a view, we can refocus the view to different elements by using
|
||||
@racket[view-left], @racket[view-right], @racket[view-up], and @racket[view-down].
|
||||
|
||||
|
||||
@defproc[(view-left? [v view]) boolean]{
|
||||
See if the view can be moved to the previous sibling.
|
||||
}
|
||||
@defproc[(view-left [v view]) view]{
|
||||
Move the focus to the previous sibling.
|
||||
}
|
||||
@defproc[(view-right? [v view]) boolean]{
|
||||
See if the view can be moved to the next sibling.
|
||||
}
|
||||
@defproc[(view-right [v view]) view]{
|
||||
Move the focus to the next sibling.}
|
||||
|
||||
@defproc[(view-up? [v view]) boolean]{
|
||||
See if the view can be moved to the parent.
|
||||
}
|
||||
@defproc[(view-up [v view]) view]{
|
||||
Move the focus to the parent.}
|
||||
|
||||
@defproc[(view-down? [v view]) boolean]{
|
||||
See if the view can be moved to the first child.
|
||||
}
|
||||
@defproc[(view-down [v view]) view]{
|
||||
Move the view to the first child.}
|
||||
|
||||
|
||||
|
||||
Once we focus the view on an element, we can bind a world handler to it that
|
||||
responds to events.
|
||||
@defproc[(view-bind [v view] [type string] [world-updater ([w world] [v view] [e event]? -> world)]) view]{
|
||||
Attach a world-updating event to the focus. When the world-updater is
|
||||
called, the view will be focused on the element that triggered the
|
||||
event. Common event types include @racket["click"],
|
||||
@racket["mouseenter"], @racket["change"].}
|
||||
|
||||
|
||||
|
||||
When the view is on an element that we'd like to query or update, we can use
|
||||
several functions:
|
||||
|
||||
@defproc[(view-text [v view]) string]{
|
||||
Get the textual content at the focus.
|
||||
}
|
||||
@defproc[(update-view-text [v view] [s string]) view]{
|
||||
Update the textual content at the focus.}
|
||||
|
||||
@defproc[(view-bind [v view] [type string] [world-updater ([w world] [v view] [e event]? -> world)]) view]{
|
||||
Attach a world-updating event to the focus.
|
||||
|
||||
Attach a world-updating event to the focus. When the world-updater is
|
||||
called, the view will be focused on the element that triggered the
|
||||
event.
|
||||
|
||||
Common event types include @racket["click"], @racket["mouseenter"], @racket["change"].}
|
||||
|
||||
@defproc[(view-show [v view]) view]{
|
||||
Show the element at the focus.
|
||||
|
|
|
@ -743,15 +743,26 @@ moment.
|
|||
}
|
||||
|
||||
|
||||
@defproc[(view-left? [v view]) boolean]{
|
||||
See if the view can be moved to the previous sibling.
|
||||
}
|
||||
@defproc[(view-left [v view]) view]{
|
||||
Move the focus to the previous sibling.
|
||||
}
|
||||
@defproc[(view-right? [v view]) boolean]{
|
||||
See if the view can be moved to the next sibling.
|
||||
}
|
||||
@defproc[(view-right [v view]) view]{
|
||||
Move the focus to the next sibling.}
|
||||
|
||||
@defproc[(view-up? [v view]) boolean]{
|
||||
See if the view can be moved to the parent.
|
||||
}
|
||||
@defproc[(view-up [v view]) view]{
|
||||
Move the focus to the parent.}
|
||||
|
||||
@defproc[(view-down? [v view]) boolean]{
|
||||
See if the view can be moved to the first child.
|
||||
}
|
||||
@defproc[(view-down [v view]) view]{
|
||||
Move the view to the first child.}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user