Make a button click from -onenter

With PSU 2.9 we have a perfect function that’s called -OnEnter but now I can’t for the life of me find out how I can make a button with a specific ID to “Click” when hitting enter. Is it possible?

do you mean -OnEnter the parameter? I’ve only seen this in the documentation for New-UDTextBox here: Textbox - PowerShell Universal

From what I understand buttons dont have this parameter, they only have -OnClick.

Why not just put whatever code you want inside the -OnEnter scriptblock for your textbox?
Alternatively if you want the same code in both but dont want to duplicate it, you could dotsource a file, use a function, or an API endpoint

I have both button and I want to use -OnEnter for Textbox.
I don’t want the code to be in both.
So I was thinking something like:

-OnEnter {
Click-UDButton -iD “button”

or similar.

The example in the docs is doing that. Invoke-UDEndpoint is calling the submit button.

New-UDTextbox -OnEnter {
    Invoke-UDEndpoint -Id 'submit'

New-UDButton -Id 'submit' -OnClick {
    Show-UDToast -Message 'From Textbox'

Sorry I did completely miss that! Thanks!

I’m getting error on this;

            New-UDGrid -Item -ExtraLargeSize 4 -LargeSize 4 -MediumSize 4 -SmallSize 6 -Children {
                New-UDTextbox -Id "txtGroupNameStart" -Icon (New-UDIcon -Icon 'users') -Label "Ange gruppnamn (Wildcard *)" -FullWidth -onEnter {
                    Invoke-UDEndpoint -Id 'MainSearch'
            New-UDGrid -Item -ExtraLargeSize 3 -LargeSize 3 -MediumSize 3 -SmallSize 4 -Children { 
                New-UDButton -Icon (New-UDIcon -Icon 'search') -Size large -OnClick {
                    $GroupName = (Get-UDElement -Id "txtGroupNameStart").value

                    if ([string]::IsNullOrEmpty($GroupName)) {
                        Sync-UDElement -Id 'GroupSearchStart'
                    elseif ($GroupName.EndsWith('*')) {
                        New-MultiSearch -ActiveEventLog $ActiveEventLog -SearchFor $GroupName -txtBoxMultiSearch "txtGroupNameStart" -MultiSearchObj "Group" -ElementSync 'GroupSearchStart'
                    else {
                        Sync-UDElement -Id 'GroupSearchStart'
                } -Id 'MainSearch'
                #New-ADGrp -EventLogName $EventLogName -ActiveEventLog $ActiveEventLog -User $User -LocalIpAddress $LocalIpAddress -RemoteIpAddress $RemoteIpAddress

There error is;


@adam can you reproduce my issue or is it something that’s wrong in my config?
I always get this error.

It was in 2.9.0 I have not tried with 2.9.2

Try include the -Session parameter on Invoke-UDEndpoint. The problem here is that you can have global endpoints (like pages) and session specific endpoints like the button. This used to make more sense in v2 when pages weren’t dynamic by default. Sorry about that.

 Invoke-UDEndpoint -Id 'MainSearch' -Session
1 Like