W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2012

Re: Clipboard API spec should specify beforecopy, beforecut, and beforepaste events

From: Ryosuke Niwa <rniwa@webkit.org>
Date: Wed, 2 May 2012 09:15:16 -0700
Message-ID: <CABNRm60A4WD0mThniz8ksup7e4CQuocvzOZ9LUih9pDmN3SNwQ@mail.gmail.com>
To: Bronislav Klučka <Bronislav.Klucka@bauglir.com>
Cc: public-webapps@w3.org
On Wed, May 2, 2012 at 8:55 AM, Bronislav Klučka <
Bronislav.Klucka@bauglir.com> wrote:

> Bear with me...
> Delphi (Object Pascal) Visual Component Library has concept of Actions,
> some Actions can be assigned to Controls (those would be here
> menu/contextmenu items of the browser, would be great to be able to assign
> such Action (or some inherited object) to my own <button>), one Action can
> be assigned to unlimited number of controls. Action has 2 important
> methods/events (either overriding the method or listening to the event
> default method triggers). First one is Execute, that is called, when
> Control default activation happens (click/enter on button, click on menu
> item), which helps to utilize functionality for several controls in one
> place (essentially one event handler function, we can do that of course in
> JS..)
> The important thing is, Action also has Update method (OnUpdate event),
> that is called every time application gets to idle state (application
> receive message (system message like click, paint, keydown, whatever),
> application processes this message and any subsequent messages if any new
> are in the queue and goes to idle). And in that idle state application goes
> through all the Actions in the application and calls Update method and then
> the Action can decide, whether is enabled or not. And all Controls with
> this Action assigned would change this property as well
>  I could express it in JS as
> var deleteUserAction = new Action();
> deleteUserAction.**addEventHandler('execute', function()
> {
>  //some code to delete all selected users
> });
> deleteUserAction.**addEventHandler('update', function()
> {
>  this.enabled = (myList.selectedUsers.length > 1) &&
> havingRightsToDeleteUsers;
> });
> mainMenuItemDelete.action = deleteUserAction;
> contextMenuItemDelete.action = deleteUserAction;
> toolbarButtonDelete.action = deleteUserAction;
> So the update handler allows you not to care about how many controls
> should you disable/enable, just assign this action to any control, in this
> action handler set up enabled to this action and all controls are updated.
> So except the assignment of Action to Control, no additional work needed.
> And the concept of calling the update method guarantees, the UI is up to
> date (user is doing something, messages are queued and processed, the
> second there is time, all actions are updated). Since it is in idle state,
> programmer does not have to care when and how to set up all controls.
> Action also has e.g. caption, image, etc. when updated again, all assigned
> controls are updated to have the same caption, image, etc...
> I'm currently trying to implement this in my web application (would be
> handy to have idle event), because it would simplify UI management on
> programmers level, but something like this could help to update browser's
> UI as well.

This is why I've suggested to tie command elements to execCommand in
http://lists.w3.org/Archives/Public/public-webapps/2011OctDec/1232.html to
be used as a state machine.

- Ryosuke
Received on Wednesday, 2 May 2012 16:16:09 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:33 UTC