Common UI UCommonButtonBase issues with Appearance Padding

Hey! I am running into issues when configuring a UCommonButtonBase widget subclass to have Appearance Padding set to nonzero and visibility set to Visible. See Steps to Reproduce for details.

I would expect repro’ing the steps above would result in neither the OnHovered or OnClicked events from firing. The desired functionality here would be needing to hover or click the button (not the padding) to fire these events. There are some easy workarounds here like either not using Appearance Padding or setting the button to Not Hit-Testable (Self Only) instead of Visible. However I was wondering if there is a better universal fix to apply here that doesn’t require other devs to be aware of this issue to avoid it.

I’m guessing the issue here is due to the nature of the widget’s slate (MyWidget) taking up the space of the widget plus the padding, while the widget’s internal button’s slate (RootButton->MyCommonButton) takes up the space of just the widget (not the padding). Since the OnHovered/OnClicked events are bound to the widget and not the internal button, they trigger on the Appearance Padding. Additionally, since UCommonButtonBase overrides IsHovered to check the internal button’s state instead of the widget’s state, IsHovered is able to return false during the OnHovered callback when hovering the Appearance Padding.

Let me know if this behavior is intended or if you have any suggestions, thanks!

Steps to Reproduce

  1. Create a subclass of UCommonButtonBase
    1. Add print statement to OnClicked
    2. Add print statement to OnHovered, print out the result of IsHovered
    3. (Add something like an image to the button so it has something to click)
  2. Add new button widget to a screen widget
    1. Set button widget visibility to Visible
    2. Give the button widget nonzero Appearance Padding (20-50 padding is sufficient)
      1. Note: this is NOT Slot Padding
  3. Start the game, open the screen holding the new button
    1. Hover the padding, notice that the OnHovered event fires, but IsHovered is false
    2. Click the padding, notice that the OnClicked event fires

Hi,

The hover issue makes sense, though you shouldn’t be seeing OnClicked fire when clicking the padding. You *would* see the MouseDown and MouseUp events fire (which also makes sense since it’s at the UserWidget level), though the typical approach here is for the CommonButtonBase to rely on it’s internal SCommonButton and bind to that button’s click handler.

It might be worth digging into why the click event is misfiring, but if the hover callback is an issue then you may be able to expand SCommonButton to expose MouseEnter/MouseLeave events, which SCommonButtonBase could bind to and refire it’s own native hover event. You’d still need to check IsHovered to see if it’s the native Slate event (from entering the UserWidget) or the callback from the inner button, but that would give you a chance to react to actually hovering the visual part of the button.

Best,

Cody

Thanks for the response! If we refire the OnHover event we will now always be firing 2 OnHover events, even in cases where there isnt Appearance Padding. This may cause issues with existing buttons that assumed the hover event would fire just once (ie playing audio on hover). For now I think we’ll stick with staying away from Appearance Padding, but we may revisit this solution in the future if we find we need to use Appearance Padding. Thanks!!