Indeterminate state in Checkbox/ToggleButton changes to Unchecked on mouse over - wpf

I have a threestate RadioButton (same issue with ToggleButton) with a custom template in WPF (using Blend 4.0) and I turn it to 'Indeterminate' state on Load. This works fine, and I want to keep it in that state till the user clicks it. The problem is it changes to Unchecked state as soon as the user puts the mouse over it.
How can I prevent this unwanted change of state from happening? Is this the default behavior or something I might have changed accidentally?
I also would like that after clicked it would chang directly to the 'Checked' state but that's a different question and I've read it might have to do with changing the order of states.

Related

React & Canvas: changing state is breaking Canvas functions

I am trying to use a parent component to control animations in a child Canvas element. Specifically I want an animation to happen when a user inputs a correct answer.
It works until the user changes the state in the parent component, and then it no longer works.
I've made a stripped-back, minimal version of my code here to show my issue: https://codesandbox.io/s/epic-leaf-08jqvy?file=/src/App.js
My desired behaviour is that the red box bounces when a user clicks submit. That happens if they don't type anything in the input box, but as soon as you enter anything into there - changing state and re-rendering the component - the button no longer triggers the animation in the Canvas child component.
As far as I can tell, the issue is to do with changing the state when inputing text. If I make a version where the input is just assigned to a variable, it works fine, but I need to be able to use state and re-render other parts of it.
I have put a console.log in the jump() function, so I can see that it is being called, but no animation is taking place in the canvas.
I assume that what's happening is that everything is being re-rendered when the state changes, and so the useRef is no longer tracking to the right thing.
Things I've tried:
putting the canvas in a memoized component to prevent it from re-rendering
using eventlisteners to see if I can trigger the animations in other ways - keydown ones work, but I need the user to be able to type, so I tried other ones (like hashchange or audio.play) but neither of those worked.
You can see the thing I'm actually trying to build here: https://papaya-platypus-86565f.netlify.app/play Basically users answer questions and an animation plays depending on whether they're right or wrong, to give it a game-y feel.
Thanks!
I like your red box as well as your reasoning. Yes, the input state changing on keystroke is causing the entire App component to re-render. Note that your App.js component has a lot going on (all good stuff), such as your Box class instantiation, your canvas instantiation, etc.
The key is to break your components into smaller parts, particularly separating stateful components from non-stateful components. We don't want your canvas re-mounting on every input change, so we make them sibling components!
Here's a working example of your code, just in smaller components:
https://codesandbox.io/s/strange-julien-d3n4zm
I hope this helps.

FocusListener on Tabs/ScaleImageLabel

I've added ScaleImageLabel to swipe Tabs. I want to calculate amount of time each tab remains in focus. I added focus listener to Tabs/ScaleImageLabel but it's not getting fired. It's working when added to the form. Any suggestions on how to achieve it?
If I understand correctly what you need is a tab selection listener. Focus listener will only work for focusable components and labels are by default non-focusable. I would recommend avoiding it since focus is used for key based navigation. It might produce different results than you would expect.

How to make CodenameOne's RadioButton respect its image constants on its pressed state?

I'm not sure if this is a bug or just something I'm missing.
I've added 2 multi-images to the constants "RadioSelectedImage" and "RadioUnselectedImage", and they work fine except in their pressed state. For example: the custom image I added to the unselected constant appears just fine in my RadioButton before any interaction, but when I press it, the image changes to the native image, and when I release it, it changes to my custom selected image as expected.
I thought the problem was with RadioButton's pressed UIID, but I don't see anything that could be changing its image. I'm deriving everything in the pressed state from the unselected state.
Furthermore, if I set the constant "IncludeNativeBool" to false, then it all works as expected, and my custom image appears even in the pressed state. I'd rather not do that though, since I rely on the native theme for some components in my app.
Am I missing something here or is this a bug? If it's the latter, is there a workaround?
It should be radioSelectedImage, radioUnselectedImage, radioSelectedFocusImage & radioUnselectedFocusImage.

Reset of VisualState manager doesn't works

How to reset a silverlight control's visual state back to "Normal" on change of visibility
In the above link, the same thing was discussed, though i have some problem with changing the state.
I have read an article says that if VS is in a state and if we force it to Goto that state it just returned with true. this is fine but in my cause, am having a button and that button is in a popup. when the button clicks, am closing the popup. while open the popup again seems the mouse hover state is applied till. Though am forcing the Vs for Normal state in popup open event it remains in the old state. While forcing the VS it returns true which means Normal state s applied but UI remains still in the Mouse hover state.
What might be the cause?

Optimal setup for warning user before exiting screen when changes have been made

I have a user control ProfileEditor in a WPF application. It has a number of input controls (TextBoxes, ComboBoxes, Radio Buttons, DatePicker). It will be used to add details for a new profile, or change details for an existing profile.
There is a requirement that if any changes have been made from the initial state (blank for a new profile, prefilled with current data for existing profile), if the user tries to leave the screen, they will first be warned that there are unsaved changes. This control will always be on a Page inside a Frame element, so leaving the screen will be either when navigating to a new Page in the Frame, or exiting the application.
What is the optimal setup for this?
I am thinking that there would be some event that would be attached to all data entry controls on the page (or maybe one event per control type) on the TextChanged or SelectionChanged events that would then set a page-level bool property as to whether or not changes have been made. Is there a way to set these using styles for all types of a control on the page at one time?
And then how would I catch the close screen event? Attach something to the Frame.Navigating event?

Resources