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"

How to access SButton from inside of OnClicked_Static(...)?

Hello.

Inside of my FMyPluginEdModeToolkit::FMyPluginEdModeToolkit(){...}, reacting to button click I would like to disable the "left" button. But how to call that "left" button from inside of OnButtonClick(...)?

The code is based on sample plugin:

 MyPluginEdModeToolkit::FMyPluginEdModeToolkit()
 
     struct Locals{
         static FReply OnButtonClick(FVector InOffset){
             //how do disable the "left" button here?
             return FReply::Handled();
         }
 
         static TSharedRef<SWidget> MakeButton(FText InLabel, const FVector InOffset){
             return SNew(SButton).Text(InLabel).OnClicked_Static(&Locals::OnButtonClick, InOffset);
         }
 
     };
 
     const float Factor = 256.0f;
 
     SAssignNew(ToolkitWidget, SBorder).HAlign(HAlign_Center).Padding(25)
     .IsEnabled_Static(&Locals::IsWidgetEnabled)
     [
         SNew(SVerticalBox)
         +SVerticalBox::Slot()
         .AutoHeight().HAlign(HAlign_Center).Padding(50)
         [
             SNew(STextBlock)
             .AutoWrapText(true)
             .Text(LOCTEXT("HelperLabel", "Plugin description."))
         ]
 
         +SVerticalBox::Slot()
         .HAlign(HAlign_Center).AutoHeight()
         [
             Locals::MakeButton(LOCTEXT("UpButtonLabel", "Up"), FVector(0, 0, Factor))
         ]
         +SVerticalBox::Slot()
         .HAlign(HAlign_Center).AutoHeight()
         [
             SNew(SHorizontalBox)
             +SHorizontalBox::Slot().AutoWidth()
             [
                 Locals::MakeButton(LOCTEXT("LeftButtonLabel", "Left"), FVector(0, -Factor, 0))
             ]
             +SHorizontalBox::Slot().AutoWidth()
             [
                 Locals::MakeButton(LOCTEXT("RightButtonLabel", "Right"), FVector(0, Factor, 0))
             ]
         ]
     ];
 
Product Version: UE 4.10
Tags:
more ▼

asked Dec 09 '15 at 07:13 AM in C++ Programming

avatar image

PolGraphic
6 1 3

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

1 answer: sort voted first

Hi there ; )

You cant do that unless you pass a pointer to a button as a function parameter OR (a better solution) dont make OnButtonClick static, make it a member of MyPluginEdModeToolkit and store the pointer to your "left" button like this:

 MyLeftButton =  Locals::MakeButton(LOCTEXT("LeftButtonLabel", "Left"), FVector(0, -Factor, 0));

then, in OnButtonClick you can will be able to access MyLeftButton pointer.

more ▼

answered Dec 11 '15 at 10:44 PM

avatar image

szyszek
610 16 12 36

(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