Commit Graph
17 Commits
Author SHA1 Message Date
dotCooCoo 90b6a7640b Scripts: palette events keep drags, drafts and frames as the person left them
Follow-up to the review of #9147 (script palettes):

- A waiting click or change that can no longer run (its control was
  disabled, hidden or removed by an earlier handler) is dropped before
  the open edit is settled, so it no longer commits or cancels a drag
  in the active document with no handler run.
- A palette title or other getter that hides or closes the palette
  while the palette is being described no longer sends that
  description to the host: the host keeps the controls the palette had
  when it was hidden.
- A typed text that matches the field's stored text is still given to
  the script, before a click, a close or on focus loss, when another
  change of that field waits, so the handler reads the typed text and
  not the waiting change.
- After a palette event's run fails to begin, the app does not retry
  and ask for a frame on every pass. It tries again after the next
  input in the window, another palette event, or a change to the
  documents' edit state, the active document or the recovery settings.
- The print test now checks that the click's handler ran after the
  print jobs were canceled, and the list test only fails when the
  earlier item's text changed.
2026-12-04 02:54:11 -08:00
dotCooCoo 6826f306ae Scripts: palette tests check the post-limit refresh and the list revision
The engine test now records what the palette's getter plays only after the
handler starts, and asserts that a refresh ran after the limit with the
run's own actions. The list test turns the item's text getter back into a
plain text before it replaces the items, so only the revision check
rejects the choice.
2026-12-02 18:15:18 -08:00
dotCooCoo 79ef692ce5 Scripts: palette events keep their checks after getters and print questions
- paletteClose with another engine's palette id no longer drops that
  palette's waiting events.
- A hidden palette is not described after a run or an add, so a
  throwing getter on it no longer fails the run; script.palettes and
  docs/mcp.md say a hidden palette lists its controls as they were.
- A check box's click rechecks the box after reading its value, so a
  getter that disables it or closes the palette stops the click.
- A list's change rechecks that the list is still enabled and visible
  after its item texts are read, and is dropped when a getter disabled
  or hid it.
- A waiting palette event does not start its run, or ask for frames,
  while the last run's print jobs wait for their answer.
- script.palette.event's help states that a change merges only after
  its palette's last waiting click or close.
2026-12-02 17:05:59 -08:00
dotCooCoo 2cf9f56194 Scripts: palette events keep their file access, hide and enabled checks
- update() takes a waiting palette event only when the run's file access
  roots reach the same files as the event's, so a handler never runs with
  less access than its palette was shown with.
- A palette event is no longer delivered to a handler after its palette
  was hidden and shown again, or after a capturing listener disabled or
  hid the control or a group above it.
- A limit that ends a handler update() took restores the run's own
  actions before the end-of-run refresh.
- A palette refresh that fails reports no unhandled rejection.
- A refused palette field text no longer replaces text typed after it.
- The script.run, script.palette.event and docs texts describe update()
  delivery, list staleness after item edits, and repeating a click or
  close dropped with an oversized text.
2026-12-02 10:49:08 -08:00
dotCooCoo 49af2bf194 Scripts: format the new palette tests 2026-12-01 22:44:40 -08:00
dotCooCoo d091abbf53 Scripts: palette handlers that update() runs play their palette's actions
- A handler that a palette's update() runs in a later run of the same
  engine plays the actions of the run that showed the palette, as a
  handler's own run does. After the handler ends, or throws out of
  update(), app.doScript plays the run's own actions again.
- script_palette_start gives the app the error of an open edit that
  cannot be settled, and the waiting events keep waiting; it no longer
  returns None, which showed nothing.
- A palette event runs no handler or listener once a getter or an
  earlier listener took its control out of the palette, and a click or
  change is dropped when a getter read for the event disabled or hid
  the control or a container above it.
- A palette list's change ends its run with an error when an item's
  text comes from a getter, an inherited property or an object.
- The run's report of unhandled rejections is made again after the
  palettes are refreshed, leaving out a rejection that a getter gave a
  handler, and stays empty after a failed run.
- A text a palette's field gave stays in the field until no change of
  that field waits, also while a run before the change set the field to
  the same text.
- The report test replaces a waiting change ahead of another field's
  change, and the modal-wait test requires that no later frame is asked
  for.
- docs/mcp.md: a list's change made before the app puts it in line is
  dropped without an error; an error a handler throws out of update()
  can be caught, and the run then keeps the handler's changes.
2026-12-01 21:45:22 -08:00
dotCooCoo 95847e92db Scripts: palette handlers play the showing run's actions, and a given text stays in its field
- A palette's handler runs take the actions of the run that first showed
  the palette (script.run's actions, or the Actions panel's in the app),
  so app.doScript in a handler plays them after that run ends too.
- An edit field keeps showing the text it gave the script while that
  change waits for a run. The text goes once the session no longer holds
  the change, or the field holds the text; a text the script refuses goes
  back in the field as typed.
2026-11-30 16:13:14 -08:00
dotCooCoo 77cc99b2bd Scripts: palette refreshes run their getters' promise jobs, and events keep their place
- A prompt, confirm or alert answer that cannot reach the script is listed
  in the report with the answer "error" instead of the answer given.
- After a named-engine run, point changes that a palette getter makes
  while the palettes are refreshed are written before the run ends.
- The promise jobs a palette getter queues during that refresh run in the
  same fuel, the host gets the controls once more after them, and their
  unhandled rejections are part of the run's report. An update() they
  call takes no waiting event.
- A waiting text change merges with a newer one only when no click or
  close of its palette waits after it.
- With nobody to ask, an open edit that cannot be finished before the run
  ends script.palette.event with that error, and the event does not wait.
- A click whose onClick getter hid the palette runs no handler, and a list
  choice whose list a text getter removed, or whose earlier item text a
  later getter changed, is refused.
- add() and remove() on a shown palette return their result when a getter
  throws while the host's copy is updated; the host gets the controls at
  the next update or when the run ends.
- In the app, a palette event whose run cannot begin shows its own error
  instead of an earlier stopped run's message.
- The overview comments, docs/mcp.md and the progress line describe the
  update() handling, the merge rule, onClose returning false and the
  named engine a palette needs.
2026-11-30 15:05:36 -08:00
dotCooCoo 7b3690163e Scripts: palette events report their own run, and dialogs keep typed texts on a failed handoff
- script.palette.event with nobody to ask answers with the report of the
  run that handled the given event, also when it took the place of an
  earlier waiting event or a run of its engine took it with update(); an
  event dropped without a run is an error, and a later event that cannot
  start leaves the given event's result. An open drag in a document other
  than the active one is refused before the event waits, and the app's
  palette start check uses the same rule.
- A palette event's handler and the refresh after a run take no waiting
  event through update(), so a later event does not run inside them. The
  refresh after a named run spends at most the unbroken-run allowance.
- A click whose button a getter removed during the event runs no handler.
- A window answer that could not reach the script lists the dialog with
  the answer "error" instead of "stop".
- In a ScriptUI dialog, Escape, ui.dialog.cancel and a click keep the typed
  texts when the run does not take the event, and a refused event asks for
  the next frame so the queued events after it go on.
- Quitting while only palettes are open asks whether to stop the run.
2026-11-30 03:31:54 -08:00
dotCooCoo 48b59a3ccc Scripts: palette events and typed texts keep their own file access scope
A waiting palette event merges with a newer one only when both have the
same file access scope, and a click or close merges only after its
palette's last waiting change. A text typed in a field keeps the scope
of each pass that edited it and goes to the script under what both that
scope and the committing pass allow; a click or close that commits it
takes those limits too. Passes recorded before the app takes them stay
separate. Scope coverage checks root containment instead of comparing
the same roots object, and the progress line describes when update()
runs a waiting event.
2026-11-29 21:28:02 -08:00
dotCooCoo 91f413e9bb Scripts: palette events keep the file scope they were given in
Queued palette events keep the file access scope of the pass that gave
them, and update() runs only the events whose scope the running script
already has. update() on a removed container throws an error the script
can catch. The palette dialog returns its events from the Dialog body,
and the palette and script window tests run their frames through
testing::part_frame.
2026-11-29 15:56:12 -08:00
dotCooCoo 037a01b521 Scripts: update() checks each waiting palette event against the palette as handlers left it
update() takes the events that wait for the run's palettes one at a time.
Before each one, the host now gets every palette's controls as the script
and the earlier handlers left them, as at the end of a run, so a click on
a control that an earlier handler disabled, hid or removed runs no handler
and is dropped. The new host function palettePending says whether an
event still waits.

An update() that a getter or a handler calls while events are being taken
takes none itself; the update() already taking them goes on with the next
one, instead of calling itself until a limit stops the run.

Docs: docs/mcp.md palette bullet.
2026-11-24 22:49:29 -08:00
dotCooCoo 73394611d1 Scripts: ScriptUI windows, groups and panels have update()
Window.update() was missing, so a palette handler that moved a progress
bar and called update() ended with an error. The window-object reference
describes update() as redrawing the window and taking the person's
waiting events, so that a Cancel button can stop a long loop
(https://extendscript.docsforadobe.dev/user-interface-tools/window-object/).

- update() on a shown palette, or on a group or panel in it, runs the
  handlers of the clicks, changes and closes that wait for the palettes
  of the run's engine, oldest first, so a loop that calls update() sees
  a Cancel button's onClick. Those events do not get runs of their own.
- In the app, an update() in the script's own code then pauses the run
  so the app draws the palette, at most once every 16 ms of the run's
  time (VectorCraft's own interval). Only an update() that pauses gives
  the host the palette's controls, so a loop of many update() calls does
  not use up the run's host-call or bridge limits. An update() in a
  handler, a callback of a built-in function, a getter or a conversion,
  and any update() on the web, does not pause the run.
- update() on the showing dialog, or a group or panel in it, runs
  without an error; the dialog shows a handler's changes when the
  handler returns. On a window that is not showing it throws an Error,
  and on a control that is not a container a TypeError. Whether a
  palette is showing comes from show() and hide(), not from its visible
  property.
- docs/mcp.md and the progress-doc line describe update().
2026-11-24 11:46:45 -08:00
dotCooCoo ab15fbb0d1 Scripts: palette events keep their errors, and palettes keep visible in step
- script.palette.event takes a whole float such as 1.0 as a list's item
  index, as a window answer does.
- With nobody to ask, an event given while an undo group is open is
  refused with the undo-group error and is not kept. An event whose run
  cannot begin, for example because a recovery copy cannot be saved,
  ends the call with its error, and the events after it keep waiting.
- A handler's error keeps its file, line and column when a palette
  getter also throws in the refresh after the run.
- A palette's controls reach the host once, after the handler's run
  ends, so a getter is read once for a run that completes.
- The refresh roots its copy of the palette list while getters run.
- hide() sets a palette's visible to false, and show() sets it to true
  once the host shows it.
- A close() inside a modal dialog's onClose does nothing, as for a
  palette; a later close runs onClose again.
- A palette list change reads the list's revision after its item texts,
  whose getters may replace the items.
- Bounds given as x, y, width and height keep their right and bottom
  edges finite.
- A palette event that waits for an open undo group asks for no frames;
  the frame that ends the group asks for the next one.
- A list choice queued in a ScriptUI dialog carries the list's items and
  revision, and is not given when a handler changed the list since. The
  status message has a row in every complete catalog.
- docs/mcp.md: with nobody to ask, the undo-group refusal and the event
  whose run cannot begin; a handler reads the files allowed with Always.
2026-11-22 17:32:54 -08:00
dotCooCoo f19e114c40 Scripts: a waiting palette event a handler made its control refuse is dropped
A click or change that waits for a palette's run is checked against the
palette's controls again before its run starts. When an earlier handler
disabled or hid the control, the event is dropped. A list's change whose
list a run changed since still ends its run with the error that says so,
unless the list can no longer take a change.
2026-11-22 15:32:54 -08:00
dotCooCoo d814cb77f3 Scripts: palette events and typed texts stay with their control when a run adds controls
A click or change that waits for a palette's run now keeps where its
control sits in the palette, and a text typed in a palette's field keeps
where its field sits, so both reach the same control after a run adds
controls before it. A waiting event whose control is gone is dropped.

ScriptUiDialog::place_of and control_at move to the engine so the
palette queue and the dialog's queued events use the same rule.
2026-11-22 13:09:54 -08:00
dotCooCoo 26e0cef48d Scripts: ScriptUI palettes stay open after the run and run their handlers in line
new Window("palette") in a script with a named #targetengine shows a
palette that stays open beside the documents after the run ends.
show() runs onShow and returns at once; hide(), show() and close()
work as for a dialog, and close() and the close box run onClose.

Each click, change or close on a palette runs its handler as a run of
its own in the palette's engine, with its own report and undo step.
While another run goes on, the event waits and runs after it, oldest
first; a newer event for the same control or close replaces a waiting
one. An error in a handler ends that run and leaves the palette open.
A palette in a script without #targetengine, or with #targetengine
main, throws an Error that asks for a #targetengine line.

Palettes close when their engine is dropped or ends with an internal
error, and when the session ends. A session keeps at most 16 palettes
and 64 waiting events.

script.palettes lists the palettes and their controls, and
script.palette.event gives a palette a click, change or close. The
script checker lists palettes under dialogs instead of hostOnly.
2026-11-22 11:19:11 -08:00