• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Avoiding no-op action messages from NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Avoiding no-op action messages from NSTextField


  • Subject: Avoiding no-op action messages from NSTextField
  • From: daniel <email@hidden>
  • Date: Wed, 26 Jan 2005 12:09:46 -0800


This is kind of an advanced newbie question, I guess. :) I want to get some feedback about how I'm handling a situation with NSTextFields in my preferences window. Everything I'm doing feels "too hard" but I don't know if there's a better way to handle this.


I aggressively observe changes to a number of text fields in my preferences dialog. I don't want to miss any change the user makes. I want to act upon that change as soon as they make it. To that end, I have all of my text fields set up to "send action on end editing" instead of only on enter.

The PROBLEM is that this strategy causes my actions to be called in scenarios where the user didn't actually do anything with the value inside the text field. For instance, whenever a text field resigns responder, my action is called. This can happen when the field happens to be "first responder" in a tab that is whisked by as the user is browsing various tabs in a window.

Normally, this redundancy is not a big deal. Just a few extra cycles that nobody notices. But I recently added the notion of "preference presets" to my app, and I want to be able to detect when the user *actually* changes something, so I can change to a custom set. With my current strategy, my app thinks the user changed something whenever a corresponding action method is called. I need to remedy this. Some approaches that come to mind are:

1. Change all of my action methods to compare the new value with existing before accepting.

2. Subclass NSTextField to cache last value and only send action to the target if it changed.

3. Change my "something changed" trigger for NSTextField to wait for text-changed notfications instead of action messages.

Am I missing something obvious here? Has anybody else dealt with a similar problem in a more elegant way? I will probably opt for choice 1 (robust action methods) because I'm dealing with a relatively small number of fields, but I thought I'd check whether anybody had deep (i.e. smart) thoughts on this subject.

Also, it strikes me that NSTextField is the only control with this "problem," because it has such a passive edit mechanism.

Daniel

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Saving *lots* of instances to disk
  • Next by Date: Re: Problems with custom NSView subclass, IBPalette, and bindings support
  • Previous by thread: Print pagebreaks with Webkit
  • Next by thread: Re: Avoiding no-op action messages from NSTextField
  • Index(es):
    • Date
    • Thread