x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

UButton set isHovered

Hi,

is it possible to set the isHovered bool of a button to true without hovering with your mouse? if so can you explain how?

thanks in advance,

Product Version: UE 4.18
Tags:
more ▼

asked Jan 26 '18 at 02:05 PM in C++ Programming

avatar image

quintendc
185 44 59 82

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

On UMG level you can't, IsHovered is not varable to begin with, it's a function that ask Slate widget if it's hovered (If you didn't noticve UMG is just Blueprint wrapper for Slate, UMG classes practically only operate Slate widgets, they not widgets from themselves):

 bool UWidget::IsHovered() const
 {
     TSharedPtr<SWidget> SafeWidget = GetCachedWidget();
     if (SafeWidget.IsValid())
     {
         return SafeWidget->IsHovered();
     }
 
     return false;
 }

you can't even override this function because it's not virtual, you need to think of some workaround. You didn't explained why you want to do it, so whatever you trying to do study code of UWidget and UButton and oyu may try to alter it's behavior by creating class from UButton but remember that you can only override virtual function (once with V icon in API reference)

https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Components/UWidget/index.html https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Components/UButton/index.html

On other hand you could on Slate level it is possible, because bIsHovered is varable and IsHovered function just forward value of it.

https://docs.unrealengine.com/latest/INT/API/Runtime/SlateCore/Widgets/SWidget/index.html

Problem is bIsHovered is protected so you can't change it from foreign class like UMG class, you would need to create Slate widget based of SButton and then create UMG widget for it to be able to use it in widget blueprints. And IsHovered function in slate is virtual so you don't need to change varable just override a function.

But i bet there some less invasive workaround for that you trying to do

more ▼

answered Jan 26 '18 at 11:58 PM

avatar image

Shadowriver
37.8k 937 172 1123

avatar image quintendc Jan 27 '18 at 12:04 AM

Hi

is it maybe possible to trigger to hoveredStyle of a button or set the hovered style on the normal style and back when "unhovered"?

im working on a way to use gamepads instead of a mouse without having a mouse cursor controlled by gamepads.

thanks in advance,

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question