How to run process with no window - windows

Process.run(
'adb',
['devices],
runInShell: true,
);
When I run the app in android studio, no black window,
But when I double-click ***.exe to run the app, it will see the black window

This is a Dart bug.
As described in the comments there, you can work around it for now by creating your own console at launch and hiding it:
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
CreateAndAttachConsole();
} else {
AllocConsole();
ShowWindow(GetConsoleWindow(), SW_HIDE);
}

Related

DismissSoftInput() for search-bar for Nativescript-Vue

Explaining the problem:
The search-bar has no way of dismissing an open keyboard. This makes
the search-bar a quite unusable as the normal user pattern is that the
user search for something and then press the item and gets navigated
there. On Android (at least on >= 5.x), the open keyboard will
continue to stay open, even on the new page.
Referring to the question on Github, anyone how to do that for Nativescript-Vue and not for Nativescript with Typescript
Updated:
Added Playground: https://play.nativescript.org/?template=play-vue&id=hrrcW9
If I minimize the app, then click on it again, the keyboard pops open again.
As you could already see in the linked issue, the feature request is closed as completed. dismissSoftInput() is a method on SearchBar now that hides the keyboard.
If you have issues still, please share your code.
Update:
It's the default behaviour of Android to focus first focusable element on fragment / activity. Adding event listeners / timeouts to remove focus from each screen might be annoying, I would prefer using a auto focus view as first element (which will not have any impact on the screen design) of my layout, that would prevent auto focusing on my text fields / search bar.
import { View } from "tns-core-modules/ui/core/view";
export class AutoFocusView extends View {
createNativeView() {
if (typeof android !== "undefined") {
const linearLayout = new android.widget.LinearLayout(this._context);
linearLayout.setFocusableInTouchMode(true);
linearLayout.setFocusable(true);
return linearLayout;
}
return super.createNativeView();
}
onLoaded() {
super.onLoaded();
if (typeof android !== 'undefined') {
this.requestFocus();
}
}
requestFocus() {
if (typeof android !== "undefined") {
const nativeViewProtected = this.nativeViewProtected;
nativeViewProtected.requestFocus();
}
}
}
Playground Sample

iOS notifications sporadic (FMX)

Following the Embarcadero docs at this link i'm testing notifications on iOS (in FMX app built with C++). I've done the follownig:
Added #include <System.Notification.hpp> to the header file
Set FMLocalNotificationPermission to true
Dropped TNotificationCenter component on the form
Then, i put the following code in a button click:
void __fastcall TForm1::ScheduleNotificationClick(TObject *Sender)
{
if (NotificationCenter1->Supported()) {
TNotification *myNotification = NotificationCenter1->CreateNotification();
__try {
myNotification->Name = "MyNotification";
myNotification->AlertBody = "C++ for your mobile device is here!";
// Fire in 10 seconds
myNotification->FireDate = Now() + EncodeTime(0, 0, 10, 0);
// Send notification to the notification center
NotificationCenter1->ScheduleNotification(myNotification);
}
__finally {
myNotification->DisposeOf();
}
}
}
Once in a while it works...but rarely and never more than once. Most of the time it doesn't at all (repeated deleting and reinstall of app).
Next, i tried the "Present the Notification Message Immediately" code they provide:
void __fastcall TForm1::PresentNotificationClick(TObject *Sender)
{
if (NotificationCenter1->Supported()) {
TNotification *myNotification = NotificationCenter1->CreateNotification();
__try {
myNotification->Name = "MyNotification";
myNotification->AlertBody = "C++ for your mobile device is here!";
// Set Icon Badge Number (for iOS) or message number (for Android) as well
myNotification->Number = 18;
myNotification->EnableSound = False;
// Send notification to the notification center
NotificationCenter1->PresentNotification(myNotification);
}
__finally {
myNotification->DisposeOf();
}
}
}
Nothing happens at all with this code. I've tried this from scratch several times and i'm as sure as i can be that i'm coding it per their examples. I'm using 10.3 (Embarcadero® C++Builder 10.3 Version 26.0.32429.4364). I would think my code has a problem except once in blue moon it works.
My target is iPhone running 12.1.4 and i've tried building with SDK11.4 and SDK12.0, no difference. When i first run app i get the "allow or don't allow" popup and my app subsequently shows up in the Notification settings - just doesn't work.
russ
UPDATE 3-25-2019: If I run that top block of code (from a button click on iPhone) it will now run everytime - but ONLY IF i immediately kill the app after clicking. 10 seconds later it fires the notification. Why won't the notification appear if i leave my app running??
Are you sure you are calling "PresentNotificationClick" from the TButton when you click it?

How to focus window after show?

I have window with global shortcut registered:
RegisterHotKey(SHOWHIDE_HOTKEY, wxMOD_CONTROL, VK_OEM_3);
with it's handle looking like this:
if (IsShown()) {
Hide();
} else {
Show();
SetFocus();
}
The hiding/showing of the window works fine, the focus part doesn't. Any ideas how can I achieve it?

how to write a toggle method to open/close a window?

I have an NSPanel window in my app that I want to toggle open and close with a button on the toolbar. This seems like a fairly basic operation, and indeed one I see in many apps (like Inspector views). However, I'm struggling to find the right way to do this.
I've looked at the performClose: and the makeKeyAndOrderFront: methods, but I can't work out how to make them work in my method. Basically, I want something like this
-(IBAction)togglePanel:(id)sender {
if ( ) //what do i put here to assess if _myPanel is already open?
// tell _myPanel to close
else {
//tell _myPanel to open
}
}
Answering my own question, here. But got what I wanted thus:
- (IBAction)togglePanel:(id)sender {
if (_myPanel.isVisible == 0)
[_myPanel makeKeyAndOrderFront:self];
else {
[_myPanel performClose:self];
}
}

In Qt app how to capture "Cmd-Q" or "Quit" menu click

In my Qt app, I have a quit routine which gracefully cleans up everything before finally quitting, else there might be a crash somewhere. The app runs in the system tray, and there is a "Quit" menu defined for the system tray icon. On the quitAction I have set the menu role so that it's merged with Mac's app menu, but I don't see my slot being called. The code is below:
QAction *quitAction = new QAction(tr("&Quit"), this);
quitAction->setMenuRole(QAction::QuitRole);
connect(quitAction, SIGNAL(triggered()), this, SLOT(quittingApp()));
I have also tried to capture the QCloseEvent on QApplication but even that doesn't seem to work.
bool MyApplication::event(QEvent *ev)
{
bool eaten = false;
switch (ev->type())
{
case QEvent::Close:
{
quittingApp(); //My quit cleanup routine
eaten = true;
break;
}
default:
eaten = QApplication::event(ev);
break;
}
return eaten;
}
Am I missing something here? What's the best way to have my own cleanup routine which is called during quit?
Connecting to the QCoreApplication::aboutToQuit signal is the best way to perform some last-second cleanup.

Resources