Announcement

Collapse
No announcement yet.

Slate/UMG hover handling

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Slate/UMG hover handling

    Hey,

    while working on the UI i've noticed that there's no straightforward way of handling widgets hovering.

    In case of Slate, you have to override mouse enter function. In case of UMG there is a mouse move event, that is executed every tick (could be solved by introducing mouse enter event which is present in Slate) and once the mouse enters widget canvas, which is bad, since that way you can't handle hovering on specific widgets within your widget.

    Why there is no 'OnHover' delegate? That first, will solve issue with the full-screen widgets, and second, that will speedup workflow for both Slate and UMG ways.

    I might be missing something here, though. Any entries are welcome

    Update: Just realized it could fit engine category better.

    Update #2: So, 5 minutes of coding and I've added hover events for button widget, both Slate and UMG. Should be easy to add it to a lower-level widget
    Click image for larger version

Name:	2015-11-15_18-57-27.png
Views:	1
Size:	8.3 KB
ID:	1166960

    P.S. It's quite confusing, SButton is a child of SBorder, while UButton isn't child of UBorder, which has no obvious reasons to do so. Would be better to add these events to border widget, since it's the one which is presumed to have hovering capabilities, if i understand it correctly.

    I'd be glad to make a pull request if anyone is interested
    Last edited by BiggestSmile; 11-15-2015, 12:41 PM.
    Alone: The Untold - a story driven horror game

    #2
    PLEASE DO! This is so simple and needed that I'm curious why it isn't still in binary version of the engine...
    How to create first person shooter game from scratch. Lots of tutorials: http://www.shootertutorial.com - celebrating 50th Tutorial!

    My Marketplace Assets

    Comment


      #3
      For consistency with existing Slate methods, you should name the events OnMouseEnter and OnMouseLeave. Look at the corresponding functions in SWidget.h, and you should figure out matching delegate signatures:

      DECLARE_DELEGATE_TwoParams( FOnMouseEnter, const FGeometry&, const FPointerEvent& )
      DECLARE_DELEGATE_OneParam( FOnMouseLeave, const FPointerEvent& )

      Comment


        #4
        Indeed, thanks for the note, I've always had problems naming things properly, will fix and issue a pull request later next week.

        Edit: forgot, actually, why i didn't name delegates this way is because there are OnMouseEnter and OnMouseLeave functions, as you said. Having some delegates called, for example "OnClicked" and other "OnMouseEnterDelegate" looks a little weird. That's why there's no delegate for this in UMG, i think.

        Here are two ways to solve this:
        1) Call it the way i did (or something else, just not OnMouseEnter/OnMouseLeave), which introduces inconsistency
        2) Call it OnMouseEnterDelegate or similar way, which introduces inconsistency

        Second one is actually a little better, but Epics might not like it anyway

        Any ideas?
        Last edited by BiggestSmile; 12-13-2015, 07:02 AM.
        Alone: The Untold - a story driven horror game

        Comment


          #5
          Looks like Epic handled that on their own. Master branch has changes that bring hover event to UMG button and maybe some other widgets

          And that's how they solved this:

          FSimpleDelegate OnHovered;
          FSimpleDelegate OnUnhovered;
          Alone: The Untold - a story driven horror game

          Comment


            #6
            Originally posted by intoxicat3 View Post
            PLEASE DO! This is so simple and needed that I'm curious why it isn't still in binary version of the engine...
            I'm in dire need of this feature too!

            Comment


              #7
              Originally posted by DeathUman View Post
              I'm in dire need of this feature too!
              It's in master branch, should be in 4.11 as well i think.
              Alone: The Untold - a story driven horror game

              Comment

              Working...
              X