I'm looking to implement a Flutter Desktop application that allows a transparent window which forwards all touch events, like Zoom screen share.
My understanding is the behaviour can be achieved in electron using:
mainWindow.setIgnoreMouseEvents(true);
const el = document.getElementById('clickThroughElement');
el.addEventListener('mouseenter', () => {
mainWindow.setIgnoreMouseEvents(true, { forward: true });
});
el.addEventListener('mouseleave', () => {
mainWindow.setIgnoreMouseEvents(false);
});
};
With Flutter Desktop still being in Alpha,
Is this feature possible?
Is there another approach?
Is it on the feature radar?
you need to change the native C++ code specifically in
windows\runner\win32_window.cpp
and comment's the SetWindowLongPtr() function
and add the following code
int extendedStyleSettings = GetWindowLong(window,GWL_EXSTYLE);
SetWindowLong(window,GWL_EXSTYLE, extendedStyleSettings | WS_EX_LAYERED | WS_EX_TRANSPARENT);
SetLayeredWindowAttributes(window, 0, 255, LWA_ALPHA);
The problem with this solution is I don't know how to get the mouse event back because this solution edit's the win32api window which initiating in the begging of the running app and hosting the flutter view
Related
I use a function that checks MediaQuery.of(context).platformBrightness to determine the platform dark-mode setting:
This is called from the didChangeAppLifecycleState() and during startup - and it mostly works, except that I find that I need to minimise and re-open the app for it to receive the updated display mode.
The MediaQuery platformBrightness value appears to not be updated when the app comes to the foreground, but if you just minimise and bring the app back to forground, it is correct. This is on the Pie emulator using SDK 29.0.2.
Is there a way to directly listen for notifications about platform dark mode?
Note: There are a number of reasons why I don't use the Flutter Theme engine - The app themes are more complex than what Flutter provides and the user is given a preference setting to override the dark mode / normal setting to force the app to go use dark mode or normal mode and even provide dark and normal mode to older versions of android. However when the user selects "Auto" for dark/normal display mode the app should follow the platform mode, and in fact should switch even if th user does not actually leave the app, such as by just pulling down the shade and setting dark mode on or off. For this I would need a way to listen to the events.
UPDATE:
Futher testing shows the the MediaQuery is in fact updated, but that the value is still reflecting the old value when didChangeAppLifecycleState() is called.
For example the following works:
#override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(
if (displayModePreferenceSetting == DISPLAY_MODE_AUTO) {
Timer(Duration(milliseconds: 333), () {
switchDisplayMode(DISPLAY_MODE_AUTO);
});
}
}
It's much simpler than I thought, though I had to find the answer by accident.
A State widget allows you to override a method didChangePlatformBrightness()
Example:
#override
void didChangePlatformBrightness() {
if (MediaQuery.of(context).platformBrightness == Brightness.dark) {
print('PROBED DISPLAY MODE: DARK');
// DO DARK MAGIC HERE
} else {
print('PROBED DISPLAY MODE: NORMAL');
// NORMAL MODE HERE
}
}
After seeing #catherinelagoon's post I also having difficulty in quite understand how to replace an object using a button so is it possible to create a button which when pressed it replaces an existing object on the screen to another object in Smartface App Studio?
I tried using the answer provided in the post however I couldn't understand it much due to I'm a beginner in using Smartface App Studio and coding itself.
Thankyou and sorry for any inconvienience
After you create an image you should add it to a Page so it can show on that page. So here is a simple code for creating and showing an image on the page.
var image = new SMF.UI.Image({
visible: false
});
Pages.Page1.add(image);
function Page1_TextButton1_OnPressed(e) {
image.visible = true;
}
I created the app for the samsung smart tv. I tested my app using the Remote test system. All the functionalities are working properly except the return key. When i press the return button it is returning to the home screen but i want my app to return to the previous screen of my app. This is working correctly while i test this in the emulator.
I checked this by giving alers in the return key functionality. It is alerting that after it is returning to the homw screen.
Can anyone help me in this
RETURN and EXIT key are followed by default behavior to closing application and going back to smart hub or tv broadcast screen.
You should implement prevent default behavior, please look at this page: http://samsungdforum.com/Guide/ref00009/sfkey_preventdefault.html
In Samsung Smart TV, RETURN default action is return to Home, as you can see in SDK documentation:
http://www.samsungdforum.com/Guide/
You must to include this line in your code:
sf.key.preventDefault();
Before your code to customize RETURN button action.
For example (case from a Switch):
case tvKey.RETURN :
sf.key.preventDefault();
window.history.go(-1);
break;
I was facing the same problem for a basic Javascript project. I resolved it by adding event.preventDefault();, for example:
Main.keyDown = function()
{
var keyCode = event.keyCode;
case tvKey.KEY_RETURN:
case tvKey.KEY_PANEL_RETURN: event.preventDefault();
}
For Apps Framework you can use this function:
sf.key.preventDefault();
Is there a way to start a gwt-app in fullscreen mode (without toolbar, navigation)?
I found only a hint to open a new window:
Window.open("SOMEURL","SOMETITLE",
"fullscreen=yes,hotkeys=no,scrollbars=no,location=no,menubar=no,status=no,
toolbar=no,resizable=no");
Is this the only way?
If yes, what's the best way to use the "Window.open" (Example)?
This works for me:
private native void requestFullscreen() /*-{
var element = $doc.documentElement;
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
}-*/;
This isn't really a GWT question - this is a browser-provided API that GWT happens to wrap for you.
It's worth noting that modern browsers have a tendency to ignore some or all of these flags. For example, good luck getting Chrome to hide its address bar. The reason for this is that if they honoured all of the flags, you could write a web app which looked exactly like a desktop app and the user wouldn't know it - which is exactly what you sound like you're trying to do!
or use https://github.com/wokier/gwt-fullscreen
Caffeinate response has been used as a basis. I also added an event to be notified of fullscreen state change.
I've successfully implemented native HTML5 Drag and Drop for moving HTML elements inside a page (just, say, a div from one place to another, nothing related to interacting with the host OS' files whatsoever). This works fine in Chrome and Safari on a PC but I can't start a drag operation in my iPad's Safari.
I've found this so far:
Using Drag and Drop From JavaScript
Safari, Dashboard, and WebKit-based
applications include support for
customizing the behavior of drag and
drop operations within your HTML
pages.
Note: This technology is supported
only on desktop versions of Safari.
For iPhone OS, use DOM Touch,
described in Handling Events (part of
Safari Web Content Guide) and Safari
DOM Additions Reference.
Here. But it's outdated (2009-06-08).
Doe's anyone know if it is possible to use native HTML5 in Mobile Safari? (I don't want javascript-framework like solutions like jQuery UI).
Thanks!
I've just been trying to get native drag&drop working in ios safari (ipad pro with 14.0.1), and I'm updating this answer as it kept coming up as my first google result (and no other q&a seems to be up to date).
Following https://developer.apple.com/library/archive/documentation/AppleApplications/Conceptual/SafariJSProgTopics/DragAndDrop.html
I have found native html5 drag&drop now works in safari, with a few specific notes;
You MUST set some data in OnDragStart's event; (the effect settings seem to be optional) Event.dataTransfer.setData('text/plain', 'hello');
you MUST Event.preventDefault(); in OnDrop otherwise safari will load the data you added (unless that's your intention)
OnDragOver event handler needs Event.preventDefault(); otherwise drop fails (unless intended, as docuemnted)
On ios safari, if you set OnDragStart's Event.dataTransfer.dropEffect='copy' and in OnDragOver's Event.dataTransfer.dropEffect='link' the drop fails (no OnDrop()); Seems to be the only combination that fails
I thought you required
CSS -webkit-user-drag: Element; and `-webkit-user-drop: element;
or if you prefer
Element.style.setProperty('webkitUserDrag','element');
Element.style.setProperty('webkitUserDrop','element');
but it seems just the usual draggable attribute is enough
Element.setAttribute('draggable',true);
This seems to be the bare minimum to drag & drop an element
Element.setAttribute('draggable',true);
function OnDragOver(Event)
{
Element.setAttribute('DragOver',true);
Event.stopPropagation(); // let child accept and don't pass up to parent element
Event.preventDefault(); // ios to accept drop
Event.dataTransfer.dropEffect = 'copy';// move has no icon? adding copy shows +
}
function OnDragLeave(Event)
{
Element.removeAttribute('DragOver');
}
function OnDrop(Event)
{
Element.removeAttribute('DragOver');
Event.preventDefault(); // dont let page attempt to load our data
Event.stopPropagation();
}
function OnDragStart(Event)
{
Event.stopPropagation(); // let child take the drag
Event.dataTransfer.dropEffect = 'move';
Event.dataTransfer.setData('text/plain', 'hello');
}
Element.addEventListener('dragstart',OnDragStart);
Element.addEventListener('drop',OnDrop);
Element.addEventListener('dragover',OnDragOver);
Element.addEventListener('dragleave',OnDragLeave);
Touch events do work now on Safari too (including Mobile). This article has nice code snippets that you can start from:
http://www.html5rocks.com/en/mobile/touch/