How to use CustomEventData in Button component Cocos Creator 3.5.0 Typescript - cocos2d-android

In the Button component we have CustomEventData. In my understanding the purpose it to send extra parameter when user tap the button.
I have tried to use it like this:
use_powerUp(par: string){
console.log("MapScreenManager::use_powerUp() = ", par);
}
The Button will call the function and I thought the CustomEventData will be automatically become 1 parameter that will fill the par parameter. But turns out it didn’t.
Can anyone guide me how to properly use the CustomEventData?
I am using Cocos Creator 3.5.0 with Typescript.

I just found the solution, it's very simple
use_powerUp(event: Event, CustomEventData)
{
}

Related

Turning on android flashlight in Qt6

Currently I'm trying to make an mobile app and I need to turn on the flash light of a mobile device. Actually I want to use it as a torch(On/off/blink etc). I searched in the qt docs and found QCamera class. But I'm unable to turn the light on. I'm using Qt 6.3.1. Can anyone help?
I'm doing something like this:
// In constructor of a widget class,
cam = new QCamera(QCameraDevice::BackFace, this); //cam is declared in the header file
// In a function, called after a button click,
// cam->setFlashMode(QCamera::FlashOn);
cam->setTorchMode(QCamera::TorchOn);
cam->start();
I added this code inside a function and called it after a button-click event. But when I click the button, nothing happens.
UPD:
What I have found interesting is, I've tried printing the return value of isFlashModeSupported() and it returns false!
QString str = cam->isFlashModeSupported(QCamera::FlashOn) ? "Flash: Yes" : "Flash: No";
ui->Flash->setText(str); // str = "Flash: No"
I'm using a phone which has controllable flash light. So what can be the reason for this kind of behaviour?

How to use Shiny.setInputValue() with the shinyjs package?

With a Javascript snippet in Chrome devtools, I can use Shiny.setInputValue('input',0) while my Shiny app is running to reset the value of an actionButton. It works well and I only need that one line.
However, I would like to use it inside my app with shinyjs.
Here is what I have in my .js script (Note that yes, shinyjs is properly set up and I am using it for many other functions throughout my app).
shinyjs.zeroInput = function(inputID) {
Shiny.setInputValue(inputID, 0);
};
I have button A which once clicked needs to reset button B to zero:
observeEvent(input$mybuttonA, {
shinyjs::js$zeroInput("mybuttonB")
})
This does not work and the chrome Javascript console outputs this when button A is clicked:
Note that using Shiny.setInputValue("mybuttonB",0) in the Chrome Javascript console works like a charm. What is going on?
I figured out what was wrong.
All I needed to do was convert the javascript function argument into a string:
shinyjs.zeroInput = function(inputID) {
Shiny.setInputValue(String(inputID), 0);
};

Making a simple message box using C++/WinRT

I'm having trouble making a simple message dialog in C++/WinRT. Something as simple as "You clicked this: press ok to continue" nothing fancy. In the standard Windows API you can simply write MessageBox() and new popup will show up where you can click ok, and you can do somthing similiar in C++/CX with
auto messageDialog = ref new Windows::UI::Popups::MessageDialog("You clicked on the button!"); messageDialog->ShowAsync();
I've tried using IMessageDialog and ContentDialog classes with no success and can't seem to find a single example out there on how to do it without getting into writing Xaml code which for my perticular project seems unnecisary for something as simple as a message box. Maybe I'm just not setting them up right? But then again there are no examples on how to set it up in the first place (in C++). What am I missing?
Thanks!
I was able to form a simple message dialog using this:
winrt::hstring Title = L"Hello";
winrt::hstring Content = L"Some cool content!";
winrt::Windows::UI::Popups::MessageDialog dialog(Content, Title);
dialog.ShowAsync();
Make sure to also include <winrt/Windows.UI.Core.h> so you can get access to the UI library.
And here is the result:

Disable native Next button in Qt installer framework

I have to disable standard next button, on my custom page via installscript.qs file.
I can disable my own button (that I created in .ui file) via .qs script like this: widget.myButton.setEnabled(false);
This man shows that native buttons represented as enumeration and I cannot disable them same way.
Controller Scripting manual page shows some interactions with native buttons. Like gui.clickButton(buttons.NextButton). I go through whole gui object man and don't found anything useful.
Qt installer framework has a native license check page with Next button logic that I need, but I have not found any samples that do it manually. (license page work because its default license page and it's logic inside framework as I understand).
Finally I found isComplete() method that can be useful for me, but it is for C++ API not for qs.
So how to disable native button via installscript.qs file?
In case someone else end ups here, I finally found a cleaner solution: a dynamic widget has a property complete that can be changed to enable and disable the "Next" button. Set it to false to disable the button.
Controller.prototype.DynamicMyWidgetCallback = function()
{
var currentWidget = gui.currentPageWidget();
if (currentWidget != null)
{
currentWidget.complete = false
}
}
The only solution i had found is call installer.setValue("canContinue" "false");
Then connect page entered event using gui.pageById(QInstaller.TargetDirectory).entered.
connect(Component.prototype.targetPageEntered);
In targetPageEntered check our value:
Component.prototype.targetPageEntered = function () {
if (installer.value("canContinue") != "true") {
gui.clickButton(buttons.BackButton);
QMessageBox.information("someid", "Installer",
"You must do smth to continue", QMessageBox.Ok);
}
}
Of course you need to change the installer.value when user complete required actions.

NSArray and Sandbox Question

I don't quite understand, but basically I am trying to click a button and have a value added to my NSMutableArray myArray which is a property. I thought my method that would be called when a button is pressed would be something like:
- (IBAction)addInterval {
NSString *string = #"test";
[self.myArray addObject:string];
}
But I don't understand why this doesn't work?
Also, is Wifi, volume control, and bluetooth all not in our sandbox to be used?thanks.
In general, in order for your IBAction to get called, it must have a parameter, e.g.
-(IBAction) addInterval: (id)sender {
}
Also, make sure you have bound the action to the button correctly inside the UI Designer - you should see it as an action outlet for the button.
To make sure your method is being called, stick a line in the method like:
NSLog(#"Called addInterval action");
Bluetooth will not work in sandbox, WiFi will work in the sense that the network connection will function, and the reachability example should help you here.
Could be one of a few things but the classic problem here is forgetting to connect the button to the action in interface builder. Have you checked that?
I'm also assuming that you've synthesized the myArray property so that you can use the dot notation.