How to handle a button double click

I know how to define and IBAction and link it to a control by (Click-Drag)ing.
But that does not make me chose what action (event for x-Microsoft) in the control am I linking to.
By other words, when I click-drag, I dont mention, anywhere that I want this action to be linked to the "Click" event of a button. So what if I want this action method to be called when a button is double clicked for example, or when the mouse moves over it.
Thanks

Hi Tony, and welcome to the Dev Forum!
The good news is Apple provides thorough documentation on tracking, interpreting and handling Cocoa mouse events. The bad news is the info is carved into pieces that are scattered all over the library. The challenge is to identify the docs that contain one or more pieces of the puzzle, and then to fit everything together.
As to double clicks, there's no NSControl equivalent to the double-click notification that many Windows controls send (e.g. BN_DOUBLECLICKED). Also, as you've seen, when connecting an event to an action method in IB, there's only one event to choose from (Cocoa Touch is different in this regard, btw. You'll have a choice of several events when connecting a UIControl object to an action method in IB, though "double-touch" isn't among them).
So how do Cocoa programmers detect a double click in, for example, an NSButton? The default action message for this class is generated by a NSLeftMouseUp event. I.e. when the left button is released while the control is tracking the cursor.
One crude but effective solution is to have the listener (the action method connected to the button) set an ivar and start a one-shot timer on the first message. If a second message is received before the timer method resets the ivar, we have a double click. Otherwise we have two single clicks.
A more general solution is based on two methods you might easily overlook. Firstly, [setContinuous:|http://developer.apple.com/mac/library/documentation/Cocoa/Refe rence/ApplicationKit/Classes/NSCellClass/Reference/NSCell.html#//appleref/doc/uid/20000074-BBCCCEAA] allows you to configure the associated NSActionCell object to send a stream of messages to the button's target instead of just one. The stream starts with the mouse down event that initiated tracking and ends with the mouse up that ends tracking (also see [trackMouse:inRect:ofView:untilMouseUp:|http://developer.apple.com/mac/library/ documentation/Cocoa/Reference/ApplicationKit/Classes/NSCellClass/Reference/NSCell.html#//appleref/doc/uid/20000074-BBCCJAFJ]).
The next piece of the puzzle is the [currentEvent|http://developer.apple.com/mac/library/documentation/Cocoa/Refere nce/ApplicationKit/Classes/NSApplicationClass/Reference/Reference.html#//appleref/occ/instm/NSApplication/currentEvent] method of NSApplication. This returns the NSEvent object the started the current event cycle, i.e., the event which caused NSButton to send the current action message.
Thus the listener has access to the stream of event objects which represents the mouse activity from the start of tracking to the end. Using the position and time stamp data from this stream, the listener can distinguish between clicks and drags (hovering is detected differently; I won't try to cover that topic in this post).
A couple reference links that might help with the rest of the puzzle:
[Handling Mouse Events|http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Ev entOverview/HandlingMouseEvents/HandlingMouseEvents.html#//apple_ref/doc/uid/100 00060i-CH6-SW1]
[Control and Cell Programming Topics for Cocoa|http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Con trolCell/ControlCell.html#//apple_ref/doc/uid/10000015i]
Hope that helps!
\- Ray

Similar Messages

  • IOS 7.1 Upgrade - home button double click not working most of the time

    Hi,
    Not sure, if anyone else had encountered this issue after upgrading to iOS7.1.
    I am using iPhone5S 32 GB and it was working fine with home button (double click, mostly used to see & close other applications running in background) till I upgraded to iOS7.1. After iOS7.1 upgrade, most of the time, I am unable to see running applications. After trying for 4-5 times, I managed to see running application
    Is there any fix or workaround for this issue?

    Settings > General > Accessibility > Home-Click Speed - Change from Default to Slow

  • How to change the button's clicked color

    Dear all,
    How to change the button's clicked color
    I want it to be white in color as my button's background color is white
    Thanks

    How to change the button's clicked colorvia the UIManager

  • How to handle Back button, Browser Refresh problem at server side.

    Hi Friends,
    How to handle Back button, Browser Refresh problem at server side in java?.
    I am able to trace that,
    request.getHeader("ACCEPT") is returning value- */*
    when the browser was refreshed and returning different MIME types
    for all other actions from browser.
    I have doubt, will the above solution works always for all servers,browsers?.
    Please also specify any solution to handle back button at server side?.
    Thanks in Advance.
    Venkat..

    I'm sorry I don't think tht's the right solution for
    the above question....
    We must be aware that whatever scripting methdologies
    we either javascript/vbscript would executed @
    client(browser) side not @ server side....
    Dud If U get a good solution keep me updated.....
    THANKS & REGARDS,
    RAHULMy dear friend ...
    the bad news is that u simply cant disable or add any listener to the back button of the browser.
    When u hit the back button of ur browser the URL gets re-executed. So in case u have a JSP then the history.forward() is the best solution. [only if the page doesnt get expired similar to secure https sites]
    Now dont say that user can have javascript disabled ...those users will have a pretty touch time browsing websites since javascripts r used extensively by almost all websites.
    But in case u have an action.do or servlet call then u need to manage it using a session variable since the request will be sent to the server rather than client.
    For multiple form submittion issues read the following article in javaworld...
    Client vs. server solutions
    Different solutions can solve this multiple form submission situation. Some transactional sites simply warn the user to wait for a response after submitting and not to submit twice. More sophisticated solutions involve either client scripting or server programming.
    In the client-only strategy, a flag is set on the first submission, and, from then on, the submit button is disabled based on this flag. While appropriate in some situations, this strategy is more or less browser dependent and not as dependable as server solutions.
    For a server-based solution, the Synchronizer Token pattern (from Core J2EE Patterns) can be applied, which requires minimal contribution from the client side. The basic idea is to set a token in a session variable before returning a transactional page to the client. This page carries the token inside a hidden field. Upon submission, request processing first tests for the presence of a valid token in the request parameter by comparing it with the one registered in the session. If the token is valid, processing can continue normally, otherwise an alternate course of action is taken. After testing, the token resets to null to prevent subsequent submissions until a new token is saved in the session, which must be done at the appropriate time based on the desired application flow of control.
    for more details refer :
    http://www.javaworld.com/javaworld/javatips/jw-javatip136.html
    Hope u got the idea.
    FYI I have been using both these ideas in my credit card payment gateway project. This concept has worked really well.

  • Flash Button Double Click

    My new site, www.joedangerrecords.com has four pages. The
    flash link buttons I chose have to be double clicked to access the
    next page, I don't know why. Most websites I've seen have single
    click links.

    It's IE-only behaviour as a result of changes Microsoft made
    last
    year to their browser, regarding how Active Content (Flash,
    Quicktime etc)
    is handled, after losing a high profile court case.
    http://blog.deconcept.com/2005/12/15/internet-explorer-eolas-changes-and-the-flash-plugin/
    Background:
    http://en.wikipedia.org/wiki/Eolas
    See also
    http://www.adobe.com/devnet/activecontent/
    If you're running Dreamweaver 8.0.2, the fix is already built
    into DW's
    interface.
    If not, try
    http://blog.deconcept.com/swfobject/
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Joe Danger" <[email protected]> wrote in
    message
    news:epqvjf$3q$[email protected]..
    > My new site, www.joedangerrecords.com has four pages.
    The flash link
    > buttons I
    > chose have to be double clicked to access the next page,
    I don't know why.
    > Most
    > websites I've seen have single click links.
    >

  • Iphone 5 Phone favorites no longer Home button double-click?

    Double-clicking the Home button on the iphone 5 no longer brings up the Phone Favorites.  Is there another shortcut way to do it or is the shortcut gone?

    Yes, it most certainly does, which is why I'm here in the first place.
    Apparently this is a feature that has been gone for a while, now that I see some older posts.  (I did try searching before posting but came up with nothing!).  Next I need to figure out how to close apps.
    Upgraded from iphone 3G so pardon my ignorance of recent and not-so-recent changes...

  • How to trigger event when double click on a tree node

    I have this code which creates new tab in a remote Java Class.
    treeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<String>>()
       @Override
       public void changed(ObservableValue<? extends TreeItem<String>> observable, TreeItem<String> oldValue, TreeItem<String> newValue)
       System.out.println("Selected Text : " + newValue.getValue());
       // Create New Tab
       Tab tabdata = new Tab();
       Label tabALabel = new Label("Test");
      tabdata.setGraphic(tabALabel);
       DataStage.addNewTab(tabdata);
    Can you tell me how I can modify the code to open new tab when I double click on a tree node. In my code the tab is opened when I click once. What event handler do I need?

    import java.util.Arrays;
    import javafx.application.Application;
    import javafx.event.EventHandler;
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.StackPane;
    import javafx.scene.control.TreeCell;
    import javafx.scene.control.TreeView;
    import javafx.scene.control.TreeItem;
    import javafx.scene.control.SelectionMode;
    import javafx.util.Callback;
    public class TreeTest extends Application {
      public static void main(String[] args) {
        launch(args);
      @Override
      public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("TreeView Test");
        primaryStage.setScene(createScene());
        primaryStage.show();
      private Scene createScene() {
        final StackPane stackPane = new StackPane();
        final TreeView<String> treeView = new TreeView<String>();
        treeView.setRoot(createModel());
        treeView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
        treeView.setCellFactory(new Callback<TreeView<String>, TreeCell<String>>() {
          @Override
          public TreeCell<String> call(TreeView<String> treeView) {
            return new ClickableTreeCell();
        stackPane.getChildren().add(treeView);
        return new Scene(stackPane);
      private TreeItem<String> createModel() {
        TreeItem<String> root = new TreeItem<String>("RootNode");
        TreeItem<String> packageA = new TreeItem<String>("package A");
        packageA.getChildren().addAll(
            Arrays.asList(new TreeItem<String>("A1"), new TreeItem<String>("A2"), new TreeItem<String>("A3"))
        TreeItem<String> packageB = new TreeItem<String>("package B");
        packageB.getChildren().addAll(
            Arrays.asList(new TreeItem<String>("B1"), new TreeItem<String>("B2"), new TreeItem<String>("B3"))
        root.getChildren().addAll(Arrays.asList(packageA, packageB));
        return root;
      private class ClickableTreeCell extends TreeCell<String> {
        ClickableTreeCell() {
          setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
              // Handle double-clicks on non-empty cells:
              if (event.getClickCount()==2 && ! isEmpty()) {
                System.out.println("Mouse double-clicked on: " + getItem());
        @Override
        protected void updateItem(String item, boolean empty) {
          super.updateItem(item, empty);
          if (empty) {
            setText(null);
          } else {
            setText(item);

  • I have both Photoshop 4 and Photoshop 6 on my computer. When I am in Bridge and want to open an image by double clicking, it automatically opens in 6. I see, when I go to "open with" 6 is listed as "default" How can I change the "double click" defult to o

    I have both Photoshop 4 and Photoshop 6 on my computer. When I am in Bridge and want to open an image by double clicking, it automatically opens in 6. I see, when I go to "open with" 6 is listed as "default" How can I change the default to open an image with a double click in 4?

    You can associate files from the Bridge level and the Desktop level.
    In Bridge CS4, go to Preferences > File Type Associations and change it to Photoshop CS4 for the file types you want.
    If you want to open files from the Windows Desktop in CS4, these are the instructions:
    Do this from the Windows Desktop:
    If you want your image file to open in Photoshop and it doesn't, right click on it and choose
    Open with > Choose default program… select Photoshop CS4 or CS6 and checkmark "always use the selected program to open this type of file".

  • How to handle Back button in IA06 BDC

    Hi all,
    I am calling IA06 inspection screen for an task list operation using BDC from my custom program. on this screen user can change the SAP data. if I save the task list then it's working fine.
    But I have one issue how to control back button, when user make any changes on this screen and click on back button because it calls all the previous screens which i skipped using BDC.
    Or for this particular functionality there is any Function module same as for Characterstics as "CLFM_OBJECT_CLASSIFICATION"
    Please advice.
    Thanks,
    Sanket Sethi

    Hi all,
    Please suggest if there is any function module/ API  to call Task list characteristic screen directly; same as for Task list classification screen using Function module CLAF_CLASSIFICATION_OF_OBJECTS.
    Thanks,
    Sanket Sethi

  • How to identify which button is clicked in an action

    Hi,
    I am just checking whether it is possible to build calculator or not in webdynpro for abap.
    I have some buttons and i have associated same action for all the buttons and in that action i would like to know which button is clicked.
    Please let me know the code for that
    Thanks
    Bala Duvvuri

    Hi Bala,
    Its possible. Just go to the action handler for the button & read the attribute ID of the WDEVENT which is passed by the framework. This id will contain the id of the button which triggered the event. Consider the code fragment below:
    method ONACTIONACTION .
        DATA:  lv_button_name type string.
        lv_button_name = wdevent->get_string( name = 'ID' ).
    endmethod.
    At the end of execution lv_button_name will have the ID of the button which triggered the event.
    Regards,
    Uday

  • How to make response to double click of mouse event

    could anyone give me some hints? I wanna a component to respond to a double click.But it triggers by single click,how to solve this problem?

    Hello,
    Let's say that 'c' is your component, you should have a code such as this one :
    c.addMouseListener(new MouseAdapter() {
       public void mouseClicked(MouseEvent e) {
          if (e.getClickCount() == 2) {
             // you have a double click on c
    });

  • How to handle radio-buttons in FB05  bdc????

    How to change Additional selections radio-button from none to Document numbers in CALL TRANSACTION BACKGROUND MODE..............................................
    Edited by: Raghavender Poosarla on Apr 8, 2008 10:32 AM

    I have BDC requirement of FB05 transaction... I am stuck at one point where this recordin is working in Foreground mode and not in Backgroung mode...The reason being there is a bit in which I am selecting a readio-button from value 'NONE' to 'Document numbers' WHICH IS HAPPENING IN FOREGROUND AND NOT IN BACKGROUND ....Can any one tell is there any special way for handling radio-buttons in recording of an transaction???

  • How Do I Adjust the Double-Click Speed in 10.8.3

    Hi. I only found this to adjust the double click speed for Lion http://support.apple.com/kb/ht4930
    but how do you adjust it if your Lion's version is 10.8.3?
    Thank you for your time.
    Have a great sunday & a nice sunday mass.
    God bless.

    For 10.8.3,  it's in System Preferences > Accessiblity > highlight Mouse & trackpad on the left.  The Double click speed slider shows on the right.  Moving it to the left gives you more time between clicks.  Moving it right gives you less time.

  • Help! How to capture a single double click???

    I want to caputre mouse double click as well as single click,
    and I used MouseAdapter.mouseClicked(MouseEvent)
    and use MouseEvent.getClickCount() to check click count,
    but I found that every double click will cause a single click event first,
    then a double click event,
    but I only want to capture a single double click,
    how can I do that??
    Thansk!!!

    if(MouseEvent.getClickCount() larger than 1) {
      // process double click
    else {
      // process single click
    }*the larger than sign is not rendered here                                                                                                                                                                                                                                                                                                                                               

  • How can I change/hack double-click behavior to include a preceding dollar symbol in the selection?

    99.999% of times I double-click a word preceded of a $ (dollar) symbol, it is a variable name, and I want to COPY it along with the word, so I don't have to re-type it when pasting it.
    Even in preview mode / visual view / when typing into actual text, I can't imagine a scenario where the dollar sign would not be part of the following word.
    Is there any way to make this dumb behavior smarter?
    Hacking into the DW files? Hacking into MacOS files?
    Thanks.

    epub is a specific format that may require another app - I don't know what that would be on 10.5.
    You can get info on the file in Finder (select the file, choose File Menu > Get Info…) the 'Open with' section will allow you to select other apps & you can also change this file & apply it to all files of that kind.
    That should solve your issue, but you still may need an ebook reader.

Maybe you are looking for

  • R12 plsql web toolkit disabled - what are the alternatives?

    We have developed a fair amount of add-on applications in our e-business suite using the plsql web toolkit (htp). This functionality has been disbaled in R12. My question to Oracle, "What is the work around for using applications we developed in 11i

  • Can i install windows on a mac book air?, if i can, do you recomend it?

    I want to buy a new macbook air but i need to use windows, but i dont know if i can install it on a macbook air and if i can install it, is it fast? Do you recomend it?

  • Error Return in bapi 'BAPI_CASE_CHANGE'

    Hello Im getting error Internal error: class CL_SCMG_CASE_API; method SAVE in Bapi "BAPI_CASE_CHANGE" to update the tables ? I have check the lock also but there is not locking in 'SE12' What to do ?

  • Fill in another form?

    I would like to ask my Form Fillers at the end if they'd like to fill out another form (for a new enrolment/entry).

  • 10.6.5 Update Experience

    I have read lots of threads and it seems many have unfortunately experienced issues updating from 10.6.4 to 10.6.5. I would like to make a positive post in a tiny attempt to strike a balance. I have a mid 2010, 15 inch, 2.53ghz Core i5 MacBook Pro wi