Using mouse click to return image coordinates.

Ok so I've been trying to figure out how to do this and it seems very complicated for something that really seems straightforward.
Anyway. I have a camera that updates an image object on the front panel using a while loop. I have another image object that is updated with a still image when the "snap" button is pressed. Now what I want to do is to click on a point in the snapped image and have the VI return the coordinates of that pixel in the image coordinate frame.
What I've got so far is an event structure in the while loop with the following to occur in the event "image object -> mouse down":
Server reference (reference to the image object) -> Property node (last mouse position) -> output screen coordinates.
I've got two errors that don't make a whole lot of sense to me (I haven't worked with event structures before): "event data node contains unwired or bad terminal" and "event structure one or more event cases have no events defined". This second one seems strange since I don't actually want anything to happen if there's no mouse click. The first one seems to refer to the element box on the left hand side of the event structure.
The above is my lastest attmpt at sorting this problem and as far as I can see it should work. whatever about the errors, am I even taking the right approach with this? I'd have thought image cordinates would be a common enough thing but search the boards here, it would appear not...
Kinda stumped here. Any help is much appreciated.
Message Edited by RoBoTzRaWsUm on 04-14-2009 08:34 AM
Solved!
Go to Solution.

Hello RoBoTzRaWsUm,
I have taken a look at your VI, which has been taking a correct approach to the data you are looking for.  As you are using and event structure, you should be looking for an event to occur.  When using a Property Node, you are trying read an attribute of a control.  However, in an Event Structure, I believe you should be using an Invoke Node.  An Invoke Node allows your to read an event or write a method with the Control Class in LabVIEW. 
1. Place down and Invoke Node from the Functions Palette in 'Programming'->'Application Control'
2. Wire your Image Control reference to it
3. Click Method, and select 'Get Last Event'
4. Right click on 'Which Events' and 'Create Constant'.  Make the constant '1' in the array
5. Read the 'Coordinates' Cluster from the left hand side of the Event Case by right clicking  and 'Create Indicator'
You will find a piece of example code attached.
Regards
George T.
Applications Engineering Specialist
National Instruments UK and Ireland
Attachments:
UKSupportMouseClick.vi ‏39 KB

Similar Messages

  • Edit Spry Menu Bar using Mouse Click

    Hello…
    I created a Spry Menu Bar and it's working just fine. But on phones and Tablets the submenu doesn't work because it's a mouseover, is it possible to change it to a mouse click?
    Thanks!

    Yes, but it needs a lot of JS coding to do so.
    A better solution is to use a jQuery or pure CSS menubar or visit http://www.projectseven.com/ for a commercial version

  • Use mouse click trigger option more than once?

    Hi, is there some way to use the "mouse click" trigger option more than once in the project? I am trying to build a menu button animate where the users click the (menu grid icon) once, and it transforms into the (x icon) and stays there until they click it again ONCE to change it back to the (menu grid icon). Other trigger actions aren't ideal, and I find that if I used the "double mouse click", the response gets a bit messy as clicking once would replay the whole sequence again. Thanks!

    At CreationComplete make a var as:
    button = -1;
    At click event of the button write:
    if (button == -1){
    sym.getSymbol("nmnmnmn").play("xicon");   // if you have a trigger in timeline to make this action that you want
    button++;
    else {
    sym.getSymbol("nmnmnmn").play("returnedicon");
    button = -1;
    Somehow like the above you'll have to do it.
    Or else you can use boolean , TRUE/FALSE

  • Can't use mouse clicker

    I was changing settings in expose and I assigned a mouse button to windows applications and now I can't click my mouse to change back the setting.
    I tried safe mode but it still can't click.
    Is there a way to reset the mouse options or the expose preferences back to default without using the mouse????
    HELP!!!

    Everyone's stumpted on this one. I called apple support and they told me to archive and install.
    It is a logitech wireless MX 700 Keyboard & Mouse. I set it on mouse button 192 out of 295. You have to leave one option for the mouse blank in the system preference for expose.
    I solved this problem by clicking both clickers (logictech, not apple, 2 clickers) or maybe it was one then the other I am not sure but it worked and I was able to get back into the system preferences to change one of the mouse button empty and was able to use my clicker.
    In conclusion good to know about this issue. I love my mac.

  • Crop image using 2 clicked points on image.

    HI,
     I want to crop an image  based on 2 clicked points.
    For ex:
    this is an image to be crop:
    take 1st click point as center and 2nd click point as radius and crop that part as square and forms new image.
    And new image should be something like this:
     This is what I want.
    I have done getting center point using code below:
    OpenFileDialog op = new OpenFileDialog();
    ImageBrush ib = new ImageBrush();
    private void Image_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
    op.Title = "Select a picture";
    op.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" +
    "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" +
    "Portable Network Graphic (*.png)|*.png";
    if (op.ShowDialog() == true)
    imgBackground.Source = new BitmapImage(new Uri(op.FileName));
    private BitmapSource CutImage(BitmapImage img, Point p1, int width, int height)
    return new CroppedBitmap(img, new Int32Rect(Convert.ToInt32(p1.X), Convert.ToInt32(p1.Y), width, height));
    double xAxis = 0.00;
    double yAxis = 0.00;
    private void imgBackground_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    Point center = e.GetPosition(imgBackground);
    Point border = e.GetPosition(imgBackground);
    xAxis = center.X;
    yAxis = center.Y;
    ib.ImageSource = CutImage(new BitmapImage(new Uri(op.FileName)), new Point(xAxis, yAxis), 300, 300);
    CanvasPanel.Background = ib;
    XAML code:
    <Button Height="70" Width="70" Margin="6,1,892,929" Name="btnBrowseImage">
    <Image x:Name="browseIcon" Source="D:\WPF\Projects\TabControlVRI_18_12_2014\Images\img.png" MouseLeftButtonDown="Image_MouseLeftButtonDown_1"/>
    </Button>
    <Image Name="imgBackground" HorizontalAlignment="Center" VerticalAlignment="Center" Height="799" Width="799" MouseLeftButtonDown="imgBackground_MouseLeftButtonDown" Stretch="Uniform">
    </Image>
    I hope now question is understandable.
    Plz, suggest me the way to get this.
    Regards,
    Viswa.

    Hi,
    I want to do in WPF coding.
    I need to add that cropped image as background to canvas in WPF.
    User have to select image and he wants to crop image using 2 points then it has to reflect as background to canvas.

  • Adobe Plugin - mouse click event on image

    Hi all, i am new to plugin development. How to write plug in application from the scratch. please explain procedure step by step.
    Thanks in advance

    > Please give me sample code for this.
    Uh, please give me money if you want me to do your work for you. ;)
    No, seriously, the API Reference and the PDF Specification give you more than enough information to return coordinates from a click - which parts are you having trouble understanding? If you tell us what you don't understand about how it works, we can help you figure out how to make it work. Teach a man to fish and all that...
    If it is a time-sensitive project, please see this post about logging a case with Adobe Acrobat Developer Support - they'll be happy to help you in a timely manner.
    http://www.adobeforums.com/webx/.59b68c9a

  • Closing a splash screen using mouse click.

    When I click the image it does not close the splash screen. What do I fix and why? Thank you.
    package splash;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.JWindow;
    public class SplashWindow2 extends JWindow {
         public SplashWindow2 (String filename, Frame f) {
              super(f);
              try {
                   JLabel l = new JLabel(new ImageIcon(filename));
                   jbInit();
              catch(Exception e) {
                   e.printStackTrace();
         private void jbInit() throws Exception {
              // Add the mouse listener
              this.addMouseListener(new java.awt.event.MouseAdapter() {
                             public void mousePressed(MouseEvent e) {
                                  this_mousePressed(e);
              getContentPane().add(l, BorderLayout.CENTER);
              // Size the image
              pack();
              // Centre the image
              Dimension screenSize =
                   Toolkit.getDefaultToolkit().getScreenSize();
              Dimension labelSize = l.getPreferredSize();
              setLocation(screenSize.width/2 - (labelSize.width/2),
                             screenSize.height/2 - (labelSize.height/2));
              setVisible(true);
         void this_mousePressed(MouseEvent e) {
              System.out.println("TESTING");
              setVisible(false);
              dispose();
         JLabel l ;
    package splash;
    import java.awt.*;
    import javax.swing.*;
    public class SplashWindow2Test
         public static void main(String[] args)
              JFrame frame = new JFrame("Splash Screen Test");
              SplashWindow1 splashWindow = new SplashWindow1("D:\\javatest\\test\\gif\\JSplash.gif", frame);
              splashWindow.show(); // Makes the window visible, brings it in front of other windows
    //          frame.setBounds(100, 100, 400, 400);
    //          frame.show();
              splashWindow.requestFocus();
    }

    try this modified code (it works) -
    package splash;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.JWindow;
    public class SplashWindow2 extends JWindow {
    public SplashWindow2 (String filename, Frame f) {
    super(f);
    try {
    l = new JLabel(new ImageIcon(filename));
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    private void jbInit() throws Exception {
    // Add the mouse listener
    this.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mousePressed(MouseEvent e) {
    this_mousePressed(e);
    getContentPane().add(l, BorderLayout.CENTER);
    // Size the image
    pack();
    // Centre the image
    Dimension screenSize =
    Toolkit.getDefaultToolkit().getScreenSize();
    Dimension labelSize = l.getPreferredSize();
    setLocation(screenSize.width/2 - (labelSize.width/2),
    screenSize.height/2 - (labelSize.height/2));
    setVisible(true);
    void this_mousePressed(MouseEvent e) {
    System.out.println("TESTING");
    setVisible(false);
    dispose();
    JLabel l ;
    package splash;
    import java.awt.*;
    import javax.swing.*;
    public class SplashWindow2Test
    public static void main(String[] args)
    JFrame frame = new JFrame("Splash Screen Test");
    SplashWindow2 splashWindow = new SplashWindow2("//D:\\javatest\\test\\gif\\JSplash.gif", frame);
    splashWindow.show(); // Makes the window visible, brings it in front of other windows
    // frame.setBounds(100, 100, 400, 400);
    // frame.show();
    splashWindow.requestFocus();
    }

  • Want to trigger at selection screen on 'X'  using mouse click event.

    I've designed a report which has two radiobuttons i would to like change the selection screen depends on the selection of the button as of now i'm selecting the button and hitting enter so that at selection screen on radiobutton group triggers.but for more user friendly I would like trigger as soon as i click on the button. Is it possible to do this?
    cheers
    Anand

    Hi,
    all the selection screen elements which u want to be appearing on the screen during one radio button should be declared as:
    SELECTION-SCREEN BEGIN OF BLOCK b_2 WITH FRAME TITLE text-001.
    *PARAMETERS:      rb_img    RADIOBUTTON GROUP rad1.
    PARAMETERS:      p_from    like bkpf-bldat modif id gr2,
                     p_to      like bkpf-bldat modif id gr2.
    SELECT-OPTIONS:  s_arobj  FOR   toa01-ar_object modif id gr2.
    SELECTION-SCREEN END OF BLOCK b_2.
    SELECTION-SCREEN BEGIN OF BLOCK b_3 WITH FRAME TITLE text-001.
    *PARAMETERS:      rb_invo   RADIOBUTTON GROUP rad1.
    SELECT-OPTIONS:  s_bukrs   FOR bkpf-bukrs modif id gr1,
                     s_belnr   FOR bkpf-belnr modif id gr1,
                     s_gjahr   FOR bkpf-gjahr modif id gr1,
    SELECTION-SCREEN END OF BLOCK b_3.
    AT SELECTION SCREEN
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF SCREEN-GROUP1 = 'GR1'.  
          IF RB_INVO  = SPACE.
            SCREEN-ACTIVE = 0.
          ELSE.
            SCREEN-ACTIVE = 1.
          ENDIF.
          MODIFY SCREEN.
        ELSEIF SCREEN-GROUP1 = 'GR2'.
          IF RB_INVO  = C_X.
            SCREEN-ACTIVE = 0.
          ELSE.
            SCREEN-ACTIVE = 1.
          ENDIF.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    Hope this helps you.
    Regards,
    Anjali

  • X Y Mouse Click Coordinates in the Request Map?

    I have a mapping application that layers several images with a clickable top layer. When I wrap the top image in a command link I don't get the x and y coordinates of the mouse click in the request map. So I've had to use a regular command button with an image property. This works fine but doesn't allow me to use partial page rendering to limit the refresh of particular images in the stack. Can the x,y coordinate of the mouse click be returned with straight ADF?
    (I"ve included the code for retreiving the x and y coordinates under the jspx code)
    <af:panelGroup type="vertical">
    <af:objectImage source="#{backing_collect2.activeSource}"/>
    <af:objectImage source="#{backing_collect2.baseSource}"
    inlineStyle="position:absolute;left:0px;top:0px"
    binding="#{backing_collect2.baseImage}"/>
    <af:objectImage source="#{backing_collect2.allPointSource}"
    inlineStyle="position:absolute;left:0px;top:0px"
    binding="#{backing_collect2.allPointImage}"/>
    <af:objectImage source="#{backing_collect2.userPointSource}"
    inlineStyle="position:absolute;left:0px;top:0px"
    binding="#{backing_collect2.userPointImage}"/>
    <af:objectImage source="#{backing_collect2.activePointSource}"
    inlineStyle="position:absolute;left:0px;top:0px"
    binding="#{backing_collect2.activePointImage}"/>
    This following fails to return x and y in the request Map, imageMapType="server"
    attr on objectImage does not help
    <af:commandLink actionListener="#{backing_collect2.processClick}"
    action="#{backing_collect2.collectAction}"
    inlineStyle="position:absolute;left:0px;top:0px">
    <af:objectImage source="#{backing_collect2.activeSource}"
    inlineStyle="position:absolute;left:0px;top:0px"/>
    </af:commandLink>
    I have to use the following regular command button to get x, y click coordinates in the request map. But using this component makes its impossible to use partial page rendering to limit refreshes of the images above.
    <h:commandButton image="#{backing_collect2.activeSource}"
    binding="#{backing_collect2.activeLayer}"
    actionListener="#{backing_collect2.processClick}"
    action="#{backing_collect2.collectAction}"
    style="position:absolute;left:0px;top:0px"/>
    </af:panelGroup>
    // Code to get x and y from the request map
    visit.setLastClickPoint(visit.getClickPoint());
    FacesContext fc = FacesContext.getCurrentInstance();
    String clientId = actionEvent.getComponent().getClientId(fc);
    java.util.Map requestParams = fc.getExternalContext().getRequestParameterMap();
    String xString =(String) requestParams.get((String)clientId + ".x");
    String yString =(String) requestParams.get((String)clientId + ".y");
    int xMouse = (new Integer(xString)).intValue();
    int yMouse = (new Integer(yString)).intValue();

    Should have added that I'm using EA14

  • Mouse Click Event Is this a bug

    &#65279; I have a applet that has popupmenus tied to certain buttons. When a use clicks on one of the
    buttons a popupmenu is displayed for that button. Originally I used Mouse Click event to show
    the popupmenu but I found that when you switched buttons mouse click wouldn't fire right. When
    I switch to a action event it worked every time instead of losing 2-3 clicks when switching
    buttons. Does anyone no why this might happen. Is it a bug in mouse click?

    The reason why mouse clicks seem to dissapear is because a mouseClicked event is only ever fired when its mousePressed and mouseReleased coordinates are the same.
    This can be a pain!! Id recomend using the mouseReleased method to register mouseClicked events, this should always be called.

  • Question about mouse clicks

    hi I hope this makes sense.
    I am using swing in my honours project and part of it uses mouse clicks to trigger different events depending on the coordinates that are clicked. However I need to distinguish whether the left or the right button has been clicked as these will call different actions. I got it all working except for the soring out bit. At the moment both buttons do the same thing.
    What I'm really asking is what do I need to add to the mouse Clicked action listener so that it recognises which button is clicked?
    hope that made sense
    thanks

    Depends on what version of Java you are using.
    This may help.
    http://forum.java.sun.com/thread.jsp?forum=31&thread=357900

  • Changing mouse click text select in term windows

    Minor nit/question -
    When you click on text in the terminal window, it only selects up to a non-word character (i.e. it stops selecting at punctuation, so trying to click on Foo::Bar to select it all, it goes first to Foo (stopped by the ':') and then selects the entire line on the next click.
    Most Linux flavors seem to go by whitespace - first click selects everything that is between whitespace, even if it includes non-alpha characters (thus you get Foo::Bar with one click); then the next click selects the whole line. Having gotten used to that, the Mac behavior is... annoying.
    So - how does one change it? Can it be user-config'd?
    Thanks for any assistance.

    I have actually found out what the issue is. I have called a javascript method onblur of the text element which is present in the suggest region. This onblur method is interfering with the mouse click event of the auto complete suggestions shown. If i remove the onblur method, everything is working fine. I have simulated the issue in the html file present in the compressed folder attached herwith. In that i am actually throwing an alert on blur where as in real scenario i have some other functionalities to be handled on blur.
         For clarity i will explain the real scenario as well. When the user selects a suggestion from the auto complete div, the value will be placed in the text box and on blur of the text box, the dataset will be filtered based on the value in the text box.  Few pointers on this issue:
    The on blur functionality does not interfere when we select a suggestion using down arrow in key board.
    If i use mouse click to select then i have to wait for few milliseconds extra with the mouse clicked on the value before releasing it, so that the selected value is available in the textbox. Within this few milliseconds, the onblur function gets executed and then self.nodeClick is executed thus placing the value in the textbox. But forcing the user to keep the mouse clicked on the value for sometime will not sound good.
         Kindly advise as to how this issue could be handled.

  • Recording a series of mouse clicks possible with Flash?

    Hi,
    I am having a go at developing a drum machine and I have a collection of buttons that play audio.
    Is there a piece of code, or somewhere I can search to record a series of mouse clicks, ideally against a timer that I could then play back?
    I have no idea if this is possible (I am sure it is) or what to search for.

    you can record mouse clicks but timing in flash is approximate so may not be suitable for what you want.
    you can use getTimer() to record the number of ms that have transpired since your app started.  and you can use mouse click listeners to record when the mouse is clicked.

  • Lose control of mouse clicker and keyboard

    When I boot up and the desktop appears everything works fine for the first 5-10 seconds, then I find I cannot use mouse clicker or keyboard. Can still move curser, however. Does anyone have any suggestions? Thanks

    Welcome to the Apple forums.
    If you could post what Mac OS you are running, how much memory you have, what Hard drive you are using, that would help folks respond to your query.

  • Getting mouse click coordinates with image button

    I'm using ADF Rich Client components in JDeveloper 11g Technology preview.
    I have to get the mouse click coordinates with an image button. In the page I put something like this:
    <af:commandButton text="commandButton1" icon="ambiente.jpg"
    actionListener="#{prova.listen}" action="#{prova.esegui}" />
    In the listener method of the managed bean I try to get the coordinates with this code:
    public void listen(ActionEvent e)
    FacesContext context = FacesContext.getCurrentInstance();
    String clientId = e.getComponent().getClientId(context);
    Map requestParams =
    context.getExternalContext().getRequestParameterMap();
    int x =
    new Integer((String) requestParams.get(clientId + ".x")).intValue();
    int y =
    new Integer((String) requestParams.get(clientId + ".y")).intValue();
    but it doesn't work. It seems that there aren't in the request the coordinates of the image point clicked. Is it true? How can I do that with ADF ?

    Hi,
    the mouse position is not part of the request parameters send. You will have to use client side JavaScript for this
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=windows-1252"/>
    <f:view>
    <af:document>
    <f:verbatim>
    <![CDATA[
    <script>
    function handleMouseCoordinates(event) {      
    alert("x: "+event.getPageX()+" y: "+event.getPageY());
    </script>
    ]]>
    </f:verbatim>
    <af:form>
    <af:commandButton text="My Click Button" icon="/images/jdev_cup.gif">
    <af:clientListener method="handleMouseCoordinates" type="click"/>
    </af:commandButton>
    </af:form>
    </af:document>
    </f:view>
    </jsp:root>
    Frank

Maybe you are looking for