none
Label MouseUp Event in Code RRS feed

  • Question

  • Hi,

    I used to use the code below to perform a button click when someone pressed 'Enter' whilst focused on a textbox:

    $textbox.Add_KeyDown({
        if ($args.Key -eq 'Enter'){
            $button.RaiseEvent((New-Object -TypeName System.Windows.RoutedEventArgs $([System.Windows.Controls.Button]::ClickEvent)))
        }
    }

    But now I want to perform a mouseup event on a label when someone presses 'Enter'  whilst focused on the textbox. I've tried the following but it isn't working: 

    $textbox.Add_KeyDown({
        if ($args.Key -eq 'Enter'){
            $label.RaiseEvent((New-Object -TypeName System.Windows.RoutedEventArgs $([System.Windows.Controls.Label]::MouseUp)))
        }
    }
    Any help is appreciated :)

    • Moved by Bill_Stewart Wednesday, September 4, 2019 7:52 PM Abandoned
    Thursday, April 4, 2019 1:41 PM

All replies

  • You can't synthesize mouse events.  They must come from the system.  A "Click" is a composite event and can be generated on a clickable object.


    \_(ツ)_/

    Thursday, April 4, 2019 4:04 PM