IBAction method with colorwell

167 views Asked by At

I have a colorwell that when clicked fires to an IBAction method. There I check to see if the new color selected is different then the default color for an event and if it is, I show a sheet dialog to the user alerting them to this.

The problem I am having is that the color picker calls the action method every time a control such as the slider is moved. This causes the action method to be called n times instead of just once, and I have to respond to the dialog n times.

In IB there is a checkbox for continuous state. If I leave it unchecked it does't call the action method at all. Most slider controls allow you to choose between continuous state or a single state, but I am not seeing this option for a color well.

Any advise appreciated;

Simple Code:

-(IBAction)colorwellManager{

      if([self shouldAlertUser] == YES){

         [self dialog:@"Your are about to change the default color" @"Confirm Button"];

      }

}

If a slider is moved on the color picker, this code executes many times.

1

There are 1 answers

0
Miek On

I found I good explanation for whats happening here:

NSColorPanel blocking mouse up events (second answer) The underlying class (NSColorPanel) needs to have it's setContinuous set to NO programmatically in addition to unchecking the colorwell's continuous state checkbox in IB. This allows the color well to call the action method only once per action.