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 644977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:27:06+00:00 2026-05-13T21:27:06+00:00

I have a very simply subclass of UIButton that will fire off a custom

  • 0

I have a very simply subclass of UIButton that will fire off a custom event when the button has been held for 2 seconds. To accomplish this, I overrode:

//
// Mouse tracking
//
- (BOOL)beginTrackingWithTouch:(UITouch *)touch 
                     withEvent:(UIEvent *)event
{
    [super beginTrackingWithTouch:touch withEvent:event];
    [self setTimeButtonPressed:[NSDate date]];

    return (YES);
}

- (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
{
    [super continueTrackingWithTouch:touch withEvent:event];
    if ([[self timeButtonPressed] timeIntervalSinceNow] > 2.0)
    {
        //
        // disable the button.  This will eventually fire the event
        // but this is just stubbed to act as a break point area.
        //
        [self setEnabled:NO];
        [self setSelected:NO];
    }

    return (YES);
}

My problem is (this is in the simulator, can’t do on device work quite yet) “continueTrackingWithTouch: withEvent:” is not being called unless the mouse is actually moved. It does not take much motion, but it does take some motion.

By returning “YES” in both of these, I should be setup to receive continuous events. Is this an oddity of the simulator or am I doing something wrong?

NOTE: userInteractionEnabled is set to YES.

NOTE2: I could setup a timer in beginTrackingWithTouch: withEvent: but that seems like more effort for something that should be simple.

  • 1 1 Answer
  • 1 View
  • 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-13T21:27:07+00:00Added an answer on May 13, 2026 at 9:27 pm

    The behaviour you’re describing is the intended behaviour. Tracking is only to keep track of movement.

    To test for duration of the touch, I would suggest to start a timer in beginTrackingWithTouch that fires the event after 2 seconds, and a test case in endTrackingWithTouch that cancels the timer.

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

Sidebar

Related Questions

I have a very simple webforms app that will allow field techs to order
I have a very simple Mac Cocoa app that just has a Web View
I have an application that contains a main Activity, which has a very simple
Very simply put: I have a class that consists mostly of static public members,
I have a very simple subclass of UIButton: @interface MyButton : UIButton @end @implementation
I have a very simply query like this: SELECT users.id, COUNT(others.id) as c FROM
I have a very simple Setup project that copies three dlls into the GAC.
I have a very simple table with two columns, but has 4.5M rows. CREATE
I have a very simple iPhone app that requires a random integer from 1-100.
I have a very simple python script that should scan a text file, which

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.