Edge manipulation detection in fullscreen mode is not working as expected in UWP app - winrt-xaml

I have a situation where manipulation events emanating from offscreen (think bezel of surface pro) are not being registered when the app is in fullscreen mode. However, they are registering as expected when the application is "maximized" (I put that in quotes because I know it's no longer officially a "thing" to be maximized).
To reproduce, create the blank application and add the code at the end of this post.
Swipe from top down, and notice an absence of any manipulation events being fired. Now click the exit full screen button then the maximize button and repeat the experiment, and you will see that manipulation events now properly fire.
It is important to start dragging offscreen.
Is this by design? Is there a gotcha that I'm not aware of? Is it a bug?
The following Xaml file:
<Page
x:Class="EdgeSwipeDetect.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:EdgeSwipeDetect"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="Green"
ManipulationMode="TranslateInertia,TranslateY"
ManipulationStarted="Grid_ManipulationStarted"
ManipulationCompleted="Grid_ManipulationCompleted"
ManipulationDelta="Grid_ManipulationDelta" />
</Page>
Code behind:
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = true;
var appView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
appView.TryEnterFullScreenMode();
}
private void Grid_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
Debug.WriteLine("ManipulationStarted");
}
private void Grid_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
Debug.WriteLine("ManipulationCompleted");
}
private void Grid_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
Debug.WriteLine("ManipulationDelta");
}
}

Related

Revit Dockable pane does not react for min width

I have dockable pane with DockPosition=Rigth and MinWidth=300.
When pane is attached to Revit everything fine, but when i move it using mouse and DockPosition is changed to Floating , the panel do not react for MinWidth and change width to ~100.
xaml behind
xaml
How do you register the panel? You can try to register the panel after application is initialized if you haven't already tried that.
UIControlledApplication _uiControlledApplication = null;
public Result OnStartup(UIControlledApplication application)
{
_uiControlledApplication = application;
application.ControlledApplication.ApplicationInitialized += OnApplicationInitialized;
return Result.Succeeded;
}
private void OnApplicationInitialized(object sender, EventArgs e)
{
RegisterDockableWindow(_uiControlledApplication);
}
private void RegisterDockableWindow(UIControlledApplication app)
{
//app.RegisterDockablePane(....)
}

How to make JavaFX ColorPicker disabled without dim appearence?

I've been trying to disable a javafx.scene.control.ColorPicker without dimming it in my UI. Meaning that I want it to look as enabled (enabled appearence), but just do not respond to any command, also not showing the table of colors on mouse click (actually disabled). This behaviour will be interchangeable with normal behaviour, according to the system state (i.e., sometimes color picker will behave as normal).
I've tried some options, but none seemed to work, as follows:
1. Use setEditable(boolean):
myColorPicker.setEditable(false);
This just doesn't work, the color picker remains editable.
2. Use setDisable(boolean) and setOpacity(double) together:
myColorPicker.setDisable(true);
myColorPicker.setOpacity(1.0f);
This makes the color picker actually not editable, and the resulting color picker appear a little less dimmed than just using setDisable(true), but still not the appearence of an enabled color picker.
3. Overriding onMouseClick(), onMousePressed() and onMouseReleased() with empty implementations:
myColorPicker.setOnMouseClicked(new EventHandler <MouseEvent>() {
public void handle(MouseEvent event) {
System.out.println("Mouse clicked.");
}
});
myColorPicker.setOnMousePressed(new EventHandler <MouseEvent>() {
public void handle(MouseEvent event) {
System.out.println("Mouse pressed.");
}
});
myColorPicker.setOnMouseReleased(new EventHandler <MouseEvent>() {
public void handle(MouseEvent event) {
System.out.println("Mouse released.");
}
});
The above approach printed on my console the corresponding messages, but color picker still responded to mouse click (showing the color table and allowing to pick a new color). Also tried to override setOnAction(EventHandler<ActionEvent>), but with same effect (except that no console printing when I clicked the color picker).
Here it is the excerpt of my FXML:
<VBox fx:controller="mypackage.ElementConfigWidget"
xmlns:fx="http://javafx.com/fxml" fx:id="root" styleClass="elementConfigPane">
<HBox id="elementInfo">
(...)
<ColorPicker fx:id="elementColor" styleClass="elementColor" />
</HBox>
(...)
</VBox>
Here it is my CSS exerpt:
.elementColor {
-fx-cursor: hand;
-fx-background-color: #fff;
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
-fx-pref-width: 50.0;
}
I actually expected setEditable(boolean) to solve my problem, by keeping the element appearence and ignoring input actions. What am I missing?
Thanks a lot!
I manage to achieve it with some CSS
.Also you need to setDisable(true) and opacity to 1.0
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ColorPicker;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
#Override
public void start(Stage primaryStage) throws Exception {
ColorPicker myColorPicker = new ColorPicker();
myColorPicker.setDisable(true);
myColorPicker.setOpacity(1.0);
Scene s = new Scene(myColorPicker);
s.getStylesheets().add(this.getClass().getResource("test.css").toExternalForm());
primaryStage.setScene(s);
primaryStage.show();
}
}
And the test.css
.color-picker > .label:disabled {
-fx-opacity : 1.0;
}

Action listeners not firing

I've been developing with codenameone for over a year, and I never ran into this problem before, I feel like I'm losing my mind. I just redesigned one part of an app I'm working on, and now the ActionListeners aren't firing. I'm attaching them to a Button and a SpanButton in the code:
ActionListener goToDoc = new ActionListener() {
String mDocId = docId;
#Override
public void actionPerformed(ActionEvent evt) {
mStateMachine.currentExpertId = mDocId;
mStateMachine.showForm("DoctorDetails", null);
}
};
name.addActionListener(goToDoc);
Util.downloadImageToStorage(mStateMachine.URL_PREFIX+"images/doctors/"+(String)value.get("doc_pic"),
"doc_post_pic_"+(String)value.get("doc_id")+".png", new Callback<Image>() {
#Override
public void onSucess(Image img) {
pic.setIcon(img.scaledWidth(mStateMachine.getProportionalWidth(.23)));
StateMachine.applyGreenBorder(pic);
pic.addActionListener(goToDoc);
pic.getParent().revalidate();
}
#Override
public void onError(Object sender, Throwable err, int errorCode, String errorMessage) {
System.out.println("Unable to download expert profile picture");
}
});
When I debug the code, the components do show that the ActionListener is attached, but the actionPerformed method is never reached, no matter how many times I click on the buttons. I experience this problem both on the simulator and on an Android device. I have yet to test on an iPhone.
Did you set a parent to be a lead component or focusable?
The reason the click event wasn't firing was because the Components weren't enabled, possibly a bug in the BUI Builder. After checking off the 'Enabled' and 'Focusable' checkboxes in the GUI Builder, and seeing they were unchecked every time I went back to that form, I just used component.setFocusable(true) and component.setEnabled(true) in the code, and it worked fine after that.

Handling Page KeyUp event

I'm writing C#/XAML UWP App.
I want to handle KeyDown event for a whole page in my app. That is, no matter what specific control on the page has focus (e.g. a TextBox, a ListView, etc. ), whenever user presses a key while on that page, I want global for the whole Page KeyDown event to be fired. In theory this should be simple - subscribing to KeyDown event when the page is navigated to or loaded, for example:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
KeyDown += SettingsPage_KeyDown;
}
In practice this does't work for all the pages, even for quite simple ones and I can't understand why. I hooked up Window.Current.CoreWindow.KeyDown event which works always and properly,
but I'd like to know what's wrong with Page's KeyDown event. Obviously there may be hundredts of reasons why this doesn't work, but are there any common? I tried setting focus to page (Programmatic, Keyboard) and still
there seems to be no rule when this event works and when it doesn't.
I am using the next code in an application for Windows IoT, and it works:
public sealed partial class YourPage: Page
{
public YourPage() //Constructor
{
this.InitializeComponent();
//Add this line
Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
}
void CoreWindow_KeyDown(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.KeyEventArgs args)
{
//todo
}
}
You could also add the KeyDown attribute in the XAML:
<Page
x:Class="WESS1.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WESS1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" KeyDown="SettingsPage_KeyDown">
And in the code behind file:
public sealed partial class SettingsPage: Page
{
public SettingsPage() //Constructor
{
this.InitializeComponent();
}
private void SettingsPage_KeyDown(object sender, KeyRoutedEventArgs e)
{
// e.g. check the value of e.Key
}
}

How to bind to observable collection in code-behind from xaml

Hi how can i bind to this observablecollection
(Mainpage.xaml.cs)
public ObservableCollection tabs = new ObservableCollection();
in xaml? I've tried
(Mainpage.xaml)
But without any luck
a common pattern would be to set a DataContext in you loaded event, assuming you want to bind it to a TabControl called tabs_control on your page:
public MainPage()
{
InitializeComponent();
Loaded += OnLoaded;
}
protected void OnLoaded(object sender, RoutedEventArgs e)
{
//Initialize tabs collection
tab_control.ItemsSource = tabs;
}
Obviously you should substitute the actually control you want to bind to.
EDIT
Base on your comments, what you could do is just setup the control to be the data context, then your XAML binding should work. so instead of above you would do this:
protected void OnLoaded(obejct sender, RoutedEventArgs e)
{
this.DataContext = this;
}
then in your XAMl you could do this:
<TabControl ItemsSource={Binding tabs} ... />
Use WPF's binding syntax for XAML.
<YourControl ItemSource="{Binding tabs} />
You also need to set the DataContext of the top level control (grid, canvas etc) to be a type that owns the tabs collection (that type in the case you didn't rename your window's class, would be Window1.
So, for example, combining that with the XAML fragment above:
<Grid DataContext="Window1">
....
....
<YourControl ItemSource="{Binding tabs} />
....
....
</Grid>

Resources