Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6153647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:07:41+00:00 2026-05-23T20:07:41+00:00

I wrote an "Agent" Cocoa app where a TextField is in the status icon’s

  • 0

I wrote an "Agent" Cocoa app where a TextField is in the status icon’s menu. The icon menu is displayed as followed:


(source: ifotos.pl)

The stepper increments or decrements the value by 5. The purpose of the text field is to press the "up" or "down" keys which achieves the same result of the value being incremented or decremented by 5.

I have found out that following code must be used - (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor doCommandBySelector:(SEL)commandSelector of NSControlTextEditingDelegate protocol.

The problem I am currently encountering is how to implement the code. My normal approach is use sth.delegate = self;. I attempted to search for an answer but the replies consisted of using to control:textView:.... I was unable to learn how to use the delegate method even with further research.

Thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:07:41+00:00Added an answer on May 23, 2026 at 8:07 pm

    You need to create an object to serve as the text field’s delegate. This can be done either in code or, if it seems appropriate, in Interface Builder. You probably already have a controller responsible for this field and the stepper control, so that is a good candidate. This delegate object is what needs to implement the method you mentioned:

    - (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor doCommandBySelector:(SEL)commandSelector
    

    This method will be called whenever the field editor* for the text field is asked to perform one of the NSResponder action messages. The field editor asks its delegate, which is the text field, what it should do, and the field in turn asks its delegate, which is your object.

    The commandSelector argument holds the name of the action message. You can therefore test for the messages you are interested in (moveUp: and moveDown: in this case) and intercept them. You perform whatever actions you like and prevent the field editor or the text field from acting on the message.

    - (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor 
      doCommandBySelector:(SEL)commandSelector {
        if( commandSelector == @selector(moveUp:) ){
            // Your increment code
            return YES;    // We handled this command; don't pass it on
        }
        if( commandSelector == @selector(moveDown:) ){
            // Your decrement code
            return YES;
        }
    
        return NO;    // Default handling of the command
    
    } 
    

    *Briefly, an NSTextView which handles input on behalf of the text field when the field is active.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I write bundles in Cocoa without much "fuzz" around it? I just
Leonid wrote in chapter iv of his book : "... Module, Block and With.
I wrote the following code: public class A { protected string Howdy = "Howdy!";
Years ago I wrote some code to "publish" data for perfmon to consume. Using
I wrote this script: $.getJSON('<%=Url.Action("JsonSave","Controler")%>', { id: newRow.Id, personId: newRow.PesronId}, function(data) { $('#grid').trigger('reloadGrid'); //{0}
I wrote the following code Date d = new Date(); CharSequence s = DateFormat.format("MMMM
I wrote a little test program to show here. Here is the source code.
I wrote a jquery code to send values to a php file $('#def_formSubmit').live("click",function(){ var
I'm looking at an old web app I wrote and it is taking about
i create two files NodeControl.xaml and NodeControl.xaml.cs , in the xaml file wrote x:Class="TreeTest.NodeControl.NodeControl"

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.