Make sure you are extending your own widget class from SCompoundWidget
Check out SWidget.h !
It has all the functions you could ever want for what you are asking
UE4 does it for you already
check these ones out:
/** @return True if this widget hovered */
**virtual bool IsHovered() const**
{
return bIsHovered;
}
/**
* Set the tool tip that should appear when this widget is hovered.
*
* @param InToolTipText the text that should appear in the tool tip
*/
**void SetToolTipText( const TAttribute<FString>& InToolTipText );**
**void SetToolTipText( const FText& InToolTipText );**
/** @return The index of the child that the mouse is currently hovering */
static int32 **FindChildUnderMouse**( const FArrangedChildren& Children, const FPointerEvent& MouseEvent );
/**
* The system calls this method to notify the widget that a mouse moved within it. This event is bubbled.
*
* @param MyGeometry The Geometry of the widget receiving the event
* @param MouseEvent Information about the input event
*
* @return Whether the event was handled along with possible requests for the system to take action.
*/
virtual FReply **OnMouseMove**( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent );
/**
* The system will use this event to notify a widget that the cursor has entered it. This event is NOT bubbled.
*
* @param MyGeometry The Geometry of the widget receiving the event
* @param MouseEvent Information about the input event
*/
virtual void **OnMouseEnter**( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent );
/**
* The system will use this event to notify a widget that the cursor has left it. This event is NOT bubbled.
*
* @param MouseEvent Information about the input event
*/
virtual void **OnMouseLeave**( const FPointerEvent& MouseEvent );
/**
* Called when the mouse wheel is spun. This event is bubbled.
*
* @param MouseEvent Mouse event
*
* @return Returns whether the event was handled, along with other possible actions
*/
virtual FReply **OnMouseWheel**( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent );