1
votes

In my Codename One app the styling is defined in css. Namely the side menu which I styled based on this great video tutorial. So I have a style defined as follows :

SideMenuTagLine {
cn1-derive: "SideCommand";
text-align: right;
padding-left: 0mm;
padding-right: 0mm;
padding-top: 1mm;
padding-bottom: 0mm;
margin-right: 3mm;
font-family: "native:ItalicLight"; 
font-size: 3mm; 
}

When I tested the tagline showed in Italic, but then I worked further on the css to add other styles and all of a sudden the tagline lost its Italic (simulator and real device).

To make it reappear I have to delete the myTheme.css.res file. But again when I make changes to a css style (not SideMenuTagLine nor SideCommand), the tagline Italic gets lost. Maybe other stylings are also lost but I did not notice.

Here is the previews that I get when the res file is first generated (starting from no existing myTheme.css.res file). One may notice that the KmLabelProgress alignment changes between the unselected and the selected tabs although I did not change it. : First generated res file

Then if I change anything in the css file (eg : color for a selector) I get the following generated res file. In this case the afore mentionned alignment changes do not occur : Generated res file after modifications in the css file

Please note : this is the behaviour too in the latest (3.7.3) CN1 plugin version (as in the previous version).

What can I do to be sure the css styles that I defined in the css file are applied ?

Any help appreciated,

Edit October 9th 2017 : Here is the beginning of the stack trace that I get when I open the generated res file with the designer from the command line :

2017-10-09 10:37:09.388:INFO:oejs.Server:jetty-8.0.y.z-SNAPSHOT
2017-10-09 10:37:09.441:INFO:oejs.AbstractConnector:Started             
[email protected]:9000 STARTING
oct. 09, 2017 10:37:09 AM org.jdesktop.application.LocalStorage getId
AVERTISSEMENT: unspecified resource Application.id using ResourceEditorApp
Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
at java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager(KeyboardFocusManager.java:216)
at java.awt.KeyboardFocusManager.processCurrentLightweightRequests(KeyboardFocusManager.java:2621)
at java.awt.KeyboardFocusManager.retargetFocusEvent(KeyboardFocusManager.java:2946)
at java.awt.Component.dispatchEventImpl(Component.java:4752)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)

Please note : the full stack trace is longer than the allowed length on SO.

1
Can you narrow down a specific change that causes the italic to get lost? Can you review the generated res file in the designer or try to manipulate styles in runtime with the simulator style editor to see what might be triggering this? - Shai Almog
Thanks Shai for your support. Removing the cn1-derive directive did not change anything : when I add or modify another style (with regard to padding, margin, font) the SideTagLine Italic gets lost (but not the derived color which remains white). Modifying again SideTagLine makes the Italic reappear again. I keep you posted if I can find something with the generated res file. - HelloWorld
The component inspector does not let me open any theme styles : Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at com.codename1.ui.util.EditableResources.getTheme(EditableResources.java:1845) at com.codename1.designer.ResourceEditorApp.main(ResourceEditorApp.java:211) - HelloWorld
The generated res file cannot be opened in the designer (error but nothing shown in the popup dialog) but the theme.res can. If I delete the generated res file, then all css defined styles are applied. But then if I change a padding somewhere then all styles are lost (except the font colors). So it looks like there is a directive in the css file which is causing problem. - HelloWorld
Uncheck the File -> XML Team Model option in the designer tool. That should solve the need to delete. What does the CSS generate in the res file? - Shai Almog

1 Answers

1
votes

As Shai indicated, this was a but in the CSS generation related to native fonts. I have fixed this bug and released a new CSS plugin (v.1.1.4). To update, simply download the latest cn1css-ant-task.jar into your project's lib directory.

https://github.com/shannah/cn1-css/releases/tag/1.1.4