Is there a way to add a listener on the Form for when the virtual keyboard shows or dissapears in Codenameone?
The reason is because I want to detect this and recalculate the size of the Form. Currently, the sizeChangedListener does not get called when the keyboard shows, and so some components are hidden from view, as I can't recalculate the sizes of the components.
See Display.getInstance().setVirtualKeyboardListener(...)
You shouldn't do that.
Keyboards resize the UI only on Android and don't have that affect on iOS/Windows. We will probably change that behavior on Android as well so relying on it in that way doesn't make sense.
Size changed is called on the form when running on Android otherwise basic stuff wouldn't work. Notice that you shouldn't rely on it for typical code, if you use scrollable containers properly and the right layout things should automatically rearrange themselves correctly.
I suggest rephrasing the question with a sample of your UI/layout and problems including screenshots. E.g. a common issue is placing a text field within a non-scrollable container so the resize logic can't do anything and it fails by making the text disappear.
Related
When using NVDA on Firefox, it reads in row-wise order in React. How can I change the reading order?
Sample code:
<Row1>
<row-item-left>{some content1-left}</row-item-left>
<row-item-right>{some content1-right}</row-item-right>
<Row1>
<Row2>
<row-item-left>{some content2-left}</row-item-left>
<row-item-right>{some content2-right}</row-item-right>
<Row2>
Now it reads, "some content1-left, some content1-right, some content2-left, and some content2-right." I want it to read, "some content1-left, some content2-left, some content1-right," and, "some content2-right."
I use tabindex. It's working fine with tabs, but I don't want to focus elements Also it's not working with arrow keys. Please help me on this.
The reading order is always the same as it appears in the accessibility tree, and the accessibility tree is built from the DOM.
This basic rule can't be changed. CSS has no effect on reading order.
So if you want the content to be read column by column instead of row by row, you have no choice but rearrange your code so that it appears in the right order in the source:
<row-item-left>{some content1-left}</row-item-left>
<row-item-left>{some content2-left}</row-item-left>
<row-item-right>{some content1-right}</row-item-right>
<row-item-right>{some content2-right}</row-item-right>
I leave CSS experts tell you how you can achieve it.
Firstly accessibility isn't about what you want, never try to change expected behaviour.
When using a screen reader it is expected that items flow from left to right, top to bottom in 99% of cases (the way you would read the page normally).
The idea is that a screen reader user gets the same experience as someone who does not need to use one.
With regards to focus, never interfere with that either if it is something that is interactive (a clickable cell, link etc.).
If something is focusable it should also have a distinctive border (this helps users who use tab to navigate due to mobility issues know where their current cursor is placed on your site.) - just an extra tip, not relevant to your question.
The current read order is correct, do not interfere with it.
With regards to using arrow keys that may be useful, just use JavaScript to intercept the key presses and move focus accordingly (give that a go and post another question with a code example if you get stuck.)
Bear in mind you should also provide a way for people to disable this arrow key behaviour as they may have changed the key bindings on their screen reader and that would cause accessibility issues if your JavaScript interferes with their preferred key bindings.
I am not sure why you said you don't want to focus the element, if your custom HTML elements have focus in the first place then adjust those elements (as you must have added a tabindex=0 or some JS to those elements in the first place to make them focusable as <divs> are not focusable by default.)
Hi,
I am trying to achieve a similar screen to the one attached here using codename one. Its such that when a question is clicked, the answer drops down beneath it. The text would also have proper line breaks as it fills the screen width.
Is there any component I can use in achieving this using codename one?
I would suggest using the Tree component and setting the icons to null explicitly. This should work reasonably well for something like that and include the animation etc.
You know, like in CCleaner app where main activity is on the left side of the app and the right side area is changeable fragment.
http://cache.filehippo.com/img/ex/3049__ccleaner1.png
How to do it? I imagine I could do it by putting all fragments in the same place and just change their visibility to show just 1 at the moment, but that would make the code a whole lot of mess.
I've done this in the past by using UserControls. It's worked nicely for things like choosing payment methods (cash, cc, cheque...).
There are a couple of options for changing the display, either have all the UserControls present on the form and hide or show them as required or have an empty placeholder panel and use a factory to construct the appropriate UserControl as needed. I've done both and it really depends on the complexity (and expected longevity and users) of the project as to which is appropriate.
Using a Model-View-Presenter pattern helped with managing all of this.
What you don't want to end up with is a massive switch statement that changes the visibility of dozens of manually positioned controls individually. I've seen it and that way lies madness.
I have inherited a large MFC application which contains a CComboBox subclass that overrides OnPaint. Currently it does all its drawing by hand (with lines and rectangles), and renders a combo box that looks decidedly Windows 98-style. However, it otherwise works great and provides a lot of useful custom functionality that we rely on, and rewriting the entire control is probably not an option.
I would like to modernize it so that the OnPaint draws in Aero style where available (falling back to the old code when modern theming is unavailable). I've done this with some other custom controls we have, like buttons, and it works great for our purposes. I know there are some tiny behaviors that it won't get right, like gentle highlights on mouse-hover, but that's not a big deal for this app.
I have access to the CVisualStylesXP ckass, so I've already got the infrastructure to make calls like OpenThemeData, GetThemeColor or DrawThemeBackground pretty easily (via LoadLibrary so we don't force Vista as a min-system). Unfortunately, I don't know the proper sequence of calls to get a nice looking combo box with the theme-appropriate border and drop-down button.
Anyone know what to do here?
Honestly, I don't know why they originally tried to override OnPaint. Is there a good reason? I'm thinking that at least 99% of the time you are just going to want to override the drawing of the items in the ComboBox. For that, you can override DrawItem, MeasureItem, and CompareItem in a derived combo box to get the functionality you want. In that case, the OS will draw the non-user content specific to each OS correctly.
I think you best shot without diving in the depth of xp theming and various system metrics is take a look at this project: http://www.codeproject.com/Articles/2584/AdvComboBox-Version-2-1
Check the OnPaint of the CAdvComboBox class - there is a full implementation of the control repainting including xp theme related issues.
Not sure if it's the same situation - but when I faced this problem (in my case with subclassed CButtons), solving it only required changing the control declaration to a pointer and creating the control dynamically.
Let's assume that your subclassed control is called CComboBoxExt.
Where you had
CComboBoxExt m_cComboBoxExt;
You'll now have
CComboBoxExt* m_pcComboBoxExt;
And on the OnInitDialog of the window where the control is placed, you create it using
m_pcComboBoxExt = new CComboBoxExt();
m_pcComboBoxExt->Create(...)
Since this is now a pointer, don't forget to call DestroyWindow() and delete the pointer on termination.
This solved my particular problem - if your control is declared in the same way, consider giving it a try.
I'm working on a project that involves creating a custom graphical editor. The graphical editor has multiple tabs, and I want to create a preview function that will show a popup with Bitmap previews of the content of each of the tabs. However, the problem I'm running into is that the content for each of the tabs must be arranged before a proper preview can be generated for it. This means going into each of the tabs to ensure that they're rendered and arranged. Then, and only then, do the previews get properly generated, otherwise the previews have a size of 0x0. Does anybody know how to force an arrange of a content control so that I can get a properly sized preview generated ?
Apparently you can just call the 'Arrange' method directly, but you have to be careful about the rectangle you pass in as a parameter, because it can adversely affect the display of your control if you just want to force the object to draw itself (ie can force it to draw out of the desired position).
Here is a link to MSDN where it discusses the "arrangeOverride" method of a control.
I'm not sure this is what you need, but this method seems to be what you're asking about.
Hope this helps!