- From: Bronislav Klučka <Bronislav.Klucka@bauglir.com>
- Date: Wed, 02 May 2012 19:58:04 +0200
- To: Ryosuke Niwa <rniwa@webkit.org>
- CC: public-webapps@w3.org
On 2.5.2012 19:07, Ryosuke Niwa wrote: > On Wed, May 2, 2012 at 9:44 AM, Bronislav Klučka > <Bronislav.Klucka@bauglir.com <mailto:Bronislav.Klucka@bauglir.com>> > wrote: > > On 2.5.2012 18:15, Ryosuke Niwa wrote: >> On Wed, May 2, 2012 at 8:55 AM, Bronislav Klučka >> <Bronislav.Klucka@bauglir.com >> <mailto: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. > Basically yes... self updatable state machine (that "self" part is > extremely important to me), but if doing so, it would be great not > to bing it some specific feature (Editing API, browser UI), but > make it more generic = usable. > > > But scripts can already do that if they don't need / want to > communicate any intents with the browser; e.g. you're implementing it > for your web app. > > - Ryosuke > Hi, Scripts can update controls, of course, but the question is (that is discussed here, that is handled by Delphi's Idle state) when to do that... B.
Received on Wednesday, 2 May 2012 17:58:32 UTC