TestRecorder with MaterialCommand in Toolbar - codenameone

In a test-class, is there any way to invoke Buttons inside the toolbar, without a name (""), which were added like this?
getToolbar().addMaterialCommandToRightBar("", FontImage.MATERIAL_PICTURE_AS_PDF, e -> createPDF());
Or can I somehow tell the test-class to show a specific form ?(which is happening when I click the button without a label).
The test recorder is not generating any code in that case. It seems that it is only working with buttons, which have a non-empty String as name, as they are simply invoked by
clickButtonByLabel("Label");

The test recorder was written before the Toolbar existed, we tried to update it for the Toolbar recently but this proved to be pretty difficult.
We have this issue that covers this bug. As a workaround you can post the command directly in the code of the test.

Related

Downshift.js as a list filter

I just wanted to try and see how Downshift could be used as a list filter, ie the "drop down" menu doesn't close.
I found that fairly easy, but then found it pretty difficult to overcome the default behaviour that when you click an item, the input is populated with its value.
I've create an example of how I would tackle this (see below), but it seems complicated. Ideally I would've liked to just do a prevent default type thing on the click handler and provided my own, but I didn't see an obvious way of doing that. What is the Downshift recommended way?
https://codesandbox.io/s/laughing-leavitt-pyruxj?file=/src/downshift/ordered-examples/02-complete-autocomplete.js (click the module preview button)
I started by overriding the click behaviour, but then found I also needed to do blur and others, and i didn't want to miss an edge case.
You should use the itemToString prop and return an empty string.
<Downshift
...
itemToString={() => ""}
>

How to add checklist on my notes app in the writing area

So, I am making a note taking app with react, and I want to make something that works like apple notes where you can click on the checkbox and it adds a new checkbox to the writing area.It keeps adding a new one when you press return/enter until you press backspace, and then you can resume typing regular text. I've been trying to do it yesterday pretty much the whole day, I found some rich editor text libraries but even though they have functionality to style the text e.g bold, italic etc. I cannot find a library that provides this specific functionality. I tried using a div with the contentEditable attribute instead of textarea but I wasn't sure what to do.
In case my explanation was bad here is an image.

Don't show the Next or Done buttons in the Android VKB

How can I prevent the showing of the Next or Done buttons of the Android VKB in a Codename One app?
Currently, for my app, they are a mess: the next button of the VKB doesn't focus the next field, but the previous. After tons of trials, I didn't find a way to make them working correctly (but there are fine on iOS and on the Simulator). I also tried to override the Layout.overridesTabIndices(com.codename1.ui.Container) and Layout.getChildrenInTraversalOrder(com.codename1.ui.Container) methods in the Form, but nothing changed on Android.
I supposed two possible causes: the use of a Form inside a Form or, more probably, the fact that I replace all the TextFields and Pickers in the same Form (and other components). Maybe the fact that the inner Form is deeply changed results in a confusion for the Android mapping of the "next" button.
That's why my request: because I didn't find a way to make the "next" button useful, I'm asking how I can avoid that it's been shown.
Thank you
Nesting forms would probably mess with the focus traversal/tab order.
Normally you should be able to override public TabIterator getTabIterator(Component start) to return a blank iterator. I'd suggest doing the same for both the parent and child form to disable the "next" feature.

Displaying Windows Forms inside unit test methods

I just discovered unit test projects in Visual Studio .NET and am using test methods to set up examples of global code I have developed.
Some global methods involve displaying reusable dialogs like a date-picker and input box. Trouble is, sometimes forms will display and sometimes they won't.
I thought it was related to modality, because I have a report preview form that can be shown modally or non-modally. When I show that non-modally, it does not display. When I show it modally, it does.
Trying my input box never works:
string input = "";
using (InputBox box = new InputBox(Title, Prompt, Default))
{
DialogResult result = box.ShowDialog();
input = box.txtInput.Text.Trim();
}
return input;
Execution stops at the "box.ShowDialog()" line, and at that point I can inspect box and see that its dimensions, location, and visibility are all properly configured -- yet I cannot see the form. I've got to cancel the test to stop everything.
I'd love to use a unit testing project to act as a playground and showcase of existing code, but it seems very limited if I can't display certain forms. I realize this is not really what unit testing is meant for, but I hoped I could build a fun little sandbox this way to help get my developers up to speed.
I finally had some consistent success (and lack thereof) based on a single form property: ShowInTaskbar.
When a form had that property set to true, such forms would NOT display from a unit test method. When that property is false, all forms display. So, here are the rules as far as I know them to make sure a form can display from a unit test:
The form should be created as a standard Windows Form item in the project.
The form should have its ShowInTaskbar property set to FALSE.
The form needs to be displayed modally (i.e. with ShowDialog()).
This has let me display and test all of my utility forms like date selectors and login screens.
I had the same issue. The dialog was blinking visible then disappearing. It was already TopMost, and I tried the other trick of setting it to visible then not visible before showdialog was called, but nothing worked.
Then I checked the other dialog that was working fine and it had ControlBox = true. I tried that, and it worked!
This is definitely applicable to the question.

iAd Producer checkbox radio buttons?

I'm new to iAd Producer - what I'm really looking for is a replacement for Dashcode, since Apple seems to have abandoned it. But while it looks as though iAd Producer CAN produce iBooks Author widgets, it seems to be missing a few fundamental objects - namely checkboxes and radio buttons.
I'm sure there's a way to hack HTML and perhaps use jQuery to get the job done, but this was a relatively simple, straightforward thing in Dashcode. Am I missing something? With tools like buttons, sliders, and such, I'd think checkboxes and radio buttons would be included.
Anybody know an EASY way to replicate Dashcode functionality in iAdProducer?
Thanks!
I've had the exact same problem for the last week and finally came across a solution. You can "escape" the checkboxes in a way by including an empty onclick property to the checkbox or label that you want to affect. This should override native code that relates to cut-and-paste gestures and make checkboxes unusable. I've had success with this in iBooks Widget Tester.
Funny... we seem to be working on the same issue at the same time. Closest I've got to a solution is to build in iAd Producer using the HTML template. There you can add in the objects that are missing using HTML code while also adding drag and drop objects available in the software.
However, while I can populate my view with checkboxes and get them to be checked in iAd Producer's preview, when I preview on my iPad, I can't check the boxes. Radio buttons remain unresponsive too.

Resources