logo       

improving KupuStateButton: small proposal: msg#00010

web.kupu.devel

Subject: improving KupuStateButton: small proposal

Hi!


The problem:
------------

Updating the visible state of buttons doesn't always work correctly. Both concepts used if a button is clicked currently have issues:

a) updating the state based on selection inspection

This is hard to implement. Currently only the common parent is inspected if a selection spans across multiple nodes. If the selection is collapsed, sometimes it is even impossible to find the correct state by DOM inspection.

b) updating the state by toggling the internal 'pressed' value

This only makes sense if the original state is detected correctly. If not, we always toggle to the wrong state.

Last but not least, the way both concepts currently work together makes things even worse: The toggling is done after the inspection. This sets the state always wrong if inspection worked correctly.


AFAICS there are two ways to resolve this:
------------------------------------------

Solution 1:

Improving what we have. This could become the better solution, but would require *a lot of* work. I can't see that anybody will do this work in the near future.

Solution 2:

At least in the repository KupuStateButton objects are only used for browser commands. The browser already maintains a state of its commands. We can get this state calling queryCommandState(command). This state is not perfect, but much better than that currently maintained by Kupu.

To use this method, ParentWithStyleChecker would need an additional 'command' argument. For best results, we could use queryCommandState *and* the existing code.

KupuStateButton would no longer maintain a 'pressed' variable, updating would always be done by inspection, including inspection of the command state of the browser.


I propose to implement solution 2, because it fixes most of the current issues by changing only a few lines of code. I don't volunteer to work on solution 1.

Any thoughts?


Cheers,

Yuppie


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise