Re: Suppresing events to avoid fibrillation



Roedy Green wrote:
I run into this problem frequently. I call it fibrillation.

Lets say I do a setText on some component. This triggers an event on
it. That event handler then might do setText's on other components.
If you are really unlucky, you get a circularity.

What would like to do is a sneaky programmatic setText that does NOT
trigger any events, other than perhaps a repaint.

What I have been doing is somewhat klutzy. I have some ad hoc
booleans. When I don't want an event to be acted on, I set the
boolean, then detect it in the event handler, and turn it off.

You need one boolean for each possible event that might be triggered.
If it is not triggered, the event improperly stays suppressed.

Is there a clean way to do this?
Use a shared model amongst all your views. Don't listen for changes on a particular visual element, but instead have the business logic handled in your model. This also will help prevent coupling your business model to GUI.

The other possibility is to check for an actual "difference" in value before setting off other events.

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
.



Relevant Pages

  • Suppresing events to avoid fibrillation
    ... This triggers an event on ... What would like to do is a sneaky programmatic setText that does NOT ... You need one boolean for each possible event that might be triggered. ... If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime. ...
    (comp.lang.java.gui)
  • RE: Progress bar sometimes refuses to refresh (but works OK with D
    ... do you mean that your long running method call returns and then an event gets ... to begin executing an event handler. ... Once the UI thread starts dispatching a message (and therefore any event ... handlers it triggers) it will run through that event handler in its entirety ...
    (microsoft.public.dotnet.framework.windowsforms)
  • DataGrid Row Changes due to user navigation
    ... Is there an event handler for the DataGrid that triggers when the Current Row ... I am trying to set up a multi-grid form that ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Suppresing events to avoid fibrillation
    ... This triggers an event on ... That event handler then might do setText's on other components. ... public void stateChanged{ ... spinner.addChangeListener(new ChangeListener() { ...
    (comp.lang.java.gui)
  • Re: Tracking form submit...
    ... Add an event handler to the form tag like this. ... The submit button triggers the onsubmit handler because that's how you ...
    (comp.lang.javascript)