web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / simulate mouse clic on...
Power Apps
Answered

simulate mouse clic on my gallery and go to the next image.

(0) ShareShare
ReportReport
Posted on by 566

Hello,

In the screenshot below I have a gallery with a cat:

 

 

image.png

 

The second screenshot in my gallery is of a dog:

 

image.png

 

In the screenshot below, I've created a button called "Bouton" on the right of my screenshot.

 

This button is outside my Gallery, so if I put the following formula in "onselect" :select(parent), this formula only works inside my Gallery.

What I'd like is to simulate a mouse click on the Cat's image via this button without using my mouse. Even better, if possible, I'd still like this button to take me directly to the Dog's image and select this image without having to use the Mouse.

I've tried these formulas so far without success:

galListData.Selected (galListData is the name of my gallery, Image8 is the name of my image object)

galListData.Selected.image8

In my image8 object in "onselect

I tried: Set(selectgal;galListData.Selected)

then on my button in "onselect" I set selectgal

Please note that i am a novice. If possible try to explain step by step.

Thank you

here is the screenshot with the button named "Bouton"

 

 image.png

 

 

 

 

Categories:
  • Michael E. Gernaey Profile Picture
    53,970 Super User 2026 Season 2 on at

    Hi @Sormick 

     

    You need to set the Default property of the gallery to do that. Since you only see one record at a time do this.

    Default Propertly

    LookUp(Mytable or Collection, Field = X)

    and it will change to that record.

     


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

     

     

  • royg Profile Picture
    on at

    Hi @Sormick ,

    To allow iterating through a collection of images you need to have them indexed.

    I'd add a App formula for that, so if for example your gallery items used to be set to:

    Filter('Shared Documents',EndsWith('Folder path', "Simpsons/")

    Create a formula called OrderedCollection:

    royg_2-1707421394611.png

    OrderedCollection = With({Simpsons:Filter('Shared Documents',EndsWith('Folder path', "Simpsons/"))},
    Ungroup(
    ForAll(Sequence(CountRows(Simpsons)),
    {
    MyRecord: Table(Index(Simpsons, Value)), 
    RowID: Value
    }),
    "MyRecord")); 

    Now that you have a RowID property for each row Set the Gallery Items property to OrderedCollection, and for the Image OnSelect property set:

    UpdateContext({SelectedIndex: If(SelectedIndex = CountRows(OrderedCollection), 1, SelectedIndex + 1)});
    UpdateContext({SelectedItem: LookUp(OrderedCollection, RowID = If(SelectedItem.RowID = CountRows(OrderedCollection), 1, SelectedItem.RowID + 1))});

    Set the Default property of the gallery to SelectedItem.

     

    Now upon clicking the image, the focused item will move to the following item until it reaches the last item and returns to the 1st one.

    royg_0-1707421289193.pngroyg_1-1707421319457.png

     

    Hope this helps

  • Sormick Profile Picture
    566 on at

    Thanks for your reply.

    I'm sorry, i am still a novice about formulas. Please could you explain where i can put the formulas above?

    My gallery name is: GaLlistdata, image object name: image8

    My images are stored on a sharepoint list as attachment.

    I retrive the filename with:

    First(galListData.Selected.'Pièces jointes').DisplayName

    'Pièces jointes' means in french : attachments

    My files are sorted with:

    Sort(ListData;ID;SortOrder.Ascending)

     

     

  • royg Profile Picture
    on at

    Try following the steps:

    1. On the left pane select App and find the Formulas property, then paste the following:

     

     

    OrderedCollection = With({SortedData:Sort(ListData,ID,SortOrder.Ascending)},
    Ungroup(
    ForAll(Sequence(CountRows(SortedData)),
    {
    MyRecord: Table(Index(SortedData, Value)), 
    RowID: Value
    }),
    "MyRecord")); 

     

     

    * Note - replace comma with a semicolon

     

    2. Set the Items property of your gallery to OrderedCollection 

     

    3. Set the Default property of your gallery to SelectedItem

     

    4. For the Image in your gallery set the OnSelect property to:

    UpdateContext({SelectedIndex: If(SelectedIndex = CountRows(OrderedCollection), 1, SelectedIndex + 1)});
    UpdateContext({SelectedItem: LookUp(OrderedCollection, RowID = If(SelectedItem.RowID = CountRows(OrderedCollection), 1, SelectedItem.RowID + 1))});

     

    Hope this helps

  • Sormick Profile Picture
    566 on at

    Thank you  it seems now that my gallery is always selected with these formulas.It seems my gallery is always selected. however what i need to do it is to select automatically the "next" image when i click on a button outside my gallery not the gallery. sorry if I misunderstood from the start

  • royg Profile Picture
    on at

    Hi @Sormick,

    no worries, in that case simply set your external button OnSelect to:

    UpdateContext({SelectedIndex: If(SelectedIndex = CountRows(OrderedCollection), 1, SelectedIndex + 1)});
    UpdateContext({SelectedItem: LookUp(OrderedCollection, RowID = If(SelectedItem.RowID = CountRows(OrderedCollection), 1, SelectedItem.RowID + 1))});

    And that should perform the same action.

    Hope this promotes you

  • Sormick Profile Picture
    566 on at

    Sorry, did not select the next ID image of my gallery. don't know why. My second image (the Dog) is not selected. 

    On my screenshot below

    i have this formula which detects the name of the selected image:

    First(galListData.Selected.'{Attachments}').DisplayName 

    which is currently "CAT"

     

    image.png

     

     

    I need to select the next image "Dog"  via my external button "Bouton" without selecting manually the image DOG on my gallery.

     

    image.png

     

     

  • royg Profile Picture
    on at

    Please share your galListData "Items" and "Default" properties

  • Sormick Profile Picture
    566 on at

    Please find the screenshots of my Gallistdata items and Default properties

    image.png

     

     image.png

     

     

     

  • Verified answer
    royg Profile Picture
    on at

    Interesting, that should have worked. Try adding a Reset(dalListData); in the button OnSelect, after the UpdateContext calls.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 339 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard