Need help catching GwtQuery Datepicker select event - gwtquery

I want to execute some code when a date is selected using the Datepicker widget that is packaged with the GWT Query UI plug-in.
My attempt is below. The widget appears on the screen, and is apparently operational; but the callback function does not fire. Can you see where I have gone wrong?
$("#pick").as(Ui).datepicker().bind(Datepicker.Event.onSelect, new Function() {
public boolean f(Event e, Object data) {
Window.alert("Date selected");
return true;
}
});

Working with the GwtQuery developer by email, I arrived at a work-around for what appears to be a bug.

Related

How to use CustomEventData in Button component Cocos Creator 3.5.0 Typescript

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)
{
}

Can't catch bluetooth headset button click event in swiftui 2.0

I am trying to simply execute code on a click of a bluetooth headset button in a SwiftUI 2.0 app, but after trying many different codes, nothing have worked... Does someone have solved this issue?
Based on apple docs and some answer I found on StackOverflow (https://stackoverflow.com/a/58249502/13207818), I tried this simple code
import SwiftUI
import MediaPlayer
struct ContentView: View {
init() {
MPRemoteCommandCenter.shared().pauseCommand.isEnabled = true
MPRemoteCommandCenter.shared().pauseCommand.addTarget(handler: { (event) in
print("Pause")
return MPRemoteCommandHandlerStatus.success
})
MPRemoteCommandCenter.shared().playCommand.isEnabled = true
MPRemoteCommandCenter.shared().playCommand.addTarget(handler: { (event) in
print("Play")
return MPRemoteCommandHandlerStatus.success
})
MPRemoteCommandCenter.shared().togglePlayPauseCommand.addTarget (handler: { (event: MPRemoteCommandEvent) -> MPRemoteCommandHandlerStatus in
// middle button (toggle/pause) is clicked
print("event:", event.command)
return .success
})
}
var body: some View {
Text("Hello World")
}
}
Of course Enabling Background Audio as per Apple doc
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
Even tried to activate my app audio session:
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playAndRecord, mode: .default, options: [.duckOthers, .allowBluetooth, .allowBluetoothA2DP])
try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation)
print("audioSession is Active")
} catch {
print("audioSession properties weren't set because of an error.")
print(error)
}
But everything failed...
Would someone know what I am doing wrong or would have faced such issue with swiftUI 2.0?
Thank in advance for your support
In general you shouldn’t do actions in the initializers of views. Since they represent the state of the UI, not the actual UI they could be broken down and created again whenever SwiftUI thinks it needs to.
Im not at my pc but You can probably get a Publisher for the pause button which you can bind to a view with onReceive
Finally, I got a solution for my issue.
I don't know how it works really behind but the audio focus wasn't on my app. So I've just played a silent sound for a second and I could play properly with my play/pause button. I know that it's not a proper solution, but it works!
This reminds me of a similar bug on the galaxy s8...
If I find a better one, I'll keep you posted.

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.

Signal when a QListView selection changes due to keyboard activity?

I have a QDialog, created with QT Designer, that looks like so:
The list of servers on the left is a QListView with a QStringListModel. Mouse clicking an item in the list view updates the form with the information for the selected item by connecting the view’s activated(QModelIndex) signal to a slot function in the dialog.
However, pressing up or down on the keyboard also changes the selected item, but no signal is emitted, so the form isn't updated to match the selected item. How can this be fixed?
The activated(QModelIndex) signal actually refers to something more than just the act of selecting. The concept is rather vague, but it's more like an act of explicit choosing. If you're just looking for notification that the current selection has changed, you can grab the selection model and connect to its updates.
MyView::MyView() {
QListView* view = new QListView(this);
connect(view->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(handleSelectionChanged(QItemSelection)));
}
...
MyView::handleSelectionChanged(const QItemSelection& selection){
if(selection.indexes().isEmpty()) {
clearMyView();
} else {
displayModelIndexInMyView(selection.indexes().first());
}
}
In the code above, displayModelIndexInMyView(QModelIndex) should be replaced with your current handler slot for activated(QModelIndex), and clearMyView() replaced with whatever it is that you want to do when there's nothing selected.
There's a lot of ways to do this, and honestly I'm not sure what is the canonical one, but I think this will work for you.
The other way is to implement QListView::currentChanged(...) virtual function.
I struggled also on a similar case with Qt6. In addition to the accepted answer, I propose this, with the new syntax it becomes (example non tested):
MyView::MyView() {
QListView* view = new QListView(this);
connect(view->selectionModel(),
&QItemSelectionModel::currentChanged,
this, &MyView::handleSelectionChanged);
}
...
MyView::handleSelectionChanged(
const QItemSelection& selection,
const QItemSelection& before){
if(selection.indexes().isEmpty()) {
clearMyView();
} else {
displayModelIndexInMyView(selection.indexes().first());
}
}

Appcelerator. Buttons in rows are unclickable

Titanium SDK version: 1.6.2 (tried with 1.7 too)
iPhone SDK version: 4.2
I am developing an iPhone app and I am fetching data from my API and presenting it in a table. In this table I got a button on each row that should allow the user to add that person to his or her contacts. The only problem with the code (I think) is that only the last button responds when being clicked. Nothing happens when I click the other buttons.
This is my code: http://pastie.org/1932098
What is wrong?
You are adding the button.addEventListener outside of the for statement, and since you are overwriting the button var with each iteration, the eventListener only attaches to the last button created.
This probably isn't the best way to work this, but to fix your problem, move the button.addEventListener inside the for statement, and then check for a unique identifier in the object that gets sent to the event. Example:
for (x=0;x<5;x++) {
var button = Titanium.UI.createButton({
height:40,
width:100,
top:50*x,
id:x
});
var label = Titanium.UI.createLabel({
text:'LABEL '+x
});
button.add(label);
win1.add(button);
button.addEventListener('click', function(e){
Ti.API.info('Button clicked '+e.source.id);
});
}
The button.id property is just made up, but now you can see which button sends the event. You could also use title, or anything else that is unique.
Other options to look at are creating unique variable names for each button, but that's probably more work. Also, instead of working with putting a button in the table row, use a label or image, then listen for the event generated by the table or row.