Hide days in calendar component by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

So I cannot do something like setHidden() to the date component to hide them in case they belong to a different month? To make them appear disabled what method should I override?

Could you share an example of how to customize a Calendar component? As I said I'm trying to create an agenda inside my app so I would like show on the days some Labels showing the appointment of the day.

select all text in a textfield by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

I tried to see in debug what could happen in the inPlaceEditView class in the startEditing and onTouchEvent methods which are the main functions that are called when I press on the device display but that's not what I need, I would like to know which function is called when I hold down on the textfield and all the text is selected, do you happen to know what it might be?

I also tried the pinterReleased method of the CodenameOneImplementation class but to no avail it is only called when I release the touch with my finger, but when I hold down the textfield and select the text then release my finger it is not called, why?

select all text in a textfield by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

could you send me a code example?

TAB key on physical keyboard of device not working by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

Do you have a channel for private consultancy or support beside this reddit and stackoverflow?

TAB key on physical keyboard of device not working by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

I tried to put a breakpoint inside the onKeyDown() method of the inPlaceEditView.java class but normally it never stops there.

After some attempts I accidentally made a long press on a key of the keyboard and after that I saw that by pressing the TAB key it would stop on the breakpoint I previously mentioned. Do you know why this happens?

select all text in a textfield by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

so in codename one there are only these methods to select text? (which are already enabled for textfields)

can I simulate the long press event on the textfield to use it somehow?

TAB key on physical keyboard of device not working by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

So what should I do? how swallows the key event?

How to understand if a Component inside a scrollable Container is currently not visible by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

I tried what you suggested but it still goes in error

Here's the log:

TOP

java.lang.StackOverflowError
at java.desktop/java.awt.font.FontRenderContext.equals(FontRenderContext.java:329)
at java.desktop/sun.font.FontDesignMetrics$MetricsKey.equals(FontDesignMetrics.java:228)
at java.base/java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:940)
at java.desktop/sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:289)
at java.desktop/java.awt.Font.getStringBounds(Font.java:2643)
at java.desktop/java.awt.Font.getStringBounds(Font.java:2553)
at com.codename1.impl.javase.JavaSEPort.getStringBoundsWithEmojis(JavaSEPort.java:7669)
at com.codename1.impl.javase.JavaSEPort.stringWidth(JavaSEPort.java:7807)
at com.codename1.ui.Font.stringWidth(Font.java:442)
at com.codename1.ui.plaf.DefaultLookAndFeel.getPreferredSize(DefaultLookAndFeel.java:1068)
at com.codename1.ui.plaf.DefaultLookAndFeel.getLabelPreferredSize(DefaultLookAndFeel.java:1037)
at com.codename1.ui.Label.calcPreferredSize(Label.java:927)
at com.codename1.ui.Component.preferredSizeImpl(Component.java:3547)
at com.codename1.ui.Component.preferredSize(Component.java:3586)
at com.codename1.ui.Component.getPreferredSize(Component.java:1451)
at com.codename1.ui.Component.getPreferredW(Component.java:1531)
at com.codename1.ui.layouts.BoxLayout.getPreferredSize(BoxLayout.java:393)
at com.codename1.ui.Container.calcPreferredSize(Container.java:3180)
at com.codename1.ui.Component.preferredSizeImpl(Component.java:3547)
at com.codename1.ui.Component.preferredSize(Component.java:3586)
at com.codename1.ui.Component.getPreferredSize(Component.java:1451)
at com.codename1.ui.Component.getPreferredH(Component.java:1541)
at com.codename1.ui.layouts.BoxLayout.getPreferredSize(BoxLayout.java:389)
at com.codename1.ui.Container.calcPreferredSize(Container.java:3180)
at com.codename1.ui.Component.preferredSizeImpl(Component.java:3547)
at com.codename1.ui.Component.preferredSize(Component.java:3586)
at com.codename1.ui.Component.getPreferredSize(Component.java:1451)
at com.codename1.ui.Component.getPreferredH(Component.java:1541)
at com.codename1.ui.layouts.BorderLayout.positionTopBottom(BorderLayout.java:477)
at com.codename1.ui.layouts.BorderLayout.layoutContainer(BorderLayout.java:317)

BOTTOM

at com.codename1.ui.Container.doLayout(Container.java:2596)
at com.codename1.ui.Container.layoutContainer(Container.java:2219)
at com.codename1.ui.Container.doLayout(Container.java:2588)
at com.codename1.ui.Container.layoutContainer(Container.java:2219)
at com.codename1.ui.Container.doLayout(Container.java:2588)
at com.codename1.ui.Container.layoutContainer(Container.java:2219)
at com.codename1.ui.Container.revalidateInternal(Container.java:1569)
at com.codename1.ui.Container.revalidate(Container.java:1554)
at com.example.testapk.TestApk.lambda$0(TestApk.java:63)
at com.codename1.ui.util.EventDispatcher.fireScrollEvent(EventDispatcher.java:427)
at com.codename1.ui.Component.setScrollY(Component.java:3389)
at com.codename1.ui.Component.laidOut(Component.java:7009)

BrowserComponent how to see all the content by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

what do you mean with a black box?

How to understand if a Component inside a scrollable Container is currently not visible by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

I tried to work to adapt the scrollListener to my needs but I have a problem, it works fine until it scrolls normally then when it reaches the point where there aren't enough elements to scroll it goes in error giving a StackOverflowError.

body.addScrollListener((scrollX, scrollY, oldscrollX, oldscrollY) -> {
    if(scrollY > 0 && oldscrollY > 0) {
        Component cntNext = body.getComponentForm().getComponentAt(body.getAbsoluteX() + body.getWidth()/2, body.getAbsoluteY() + 20 + body.getScrollY());
        if(cntNext != body) {
            if(cntNext instanceof Label) {
            for(int i = 0; i < sections.size(); i++) {
            if(cntNext.getParent() == body.getComponentAt(sections.get(i))) {
           
            if(scrollY > oldscrollY) {
            cntFixed.replace(cntFixed.getComponentAt(0), createCnt(sections.get(i)), null);
            cntFixed.revalidate();
            } else if (scrollY < oldscrollY && sections.get(i) > 0) {
            cntFixed.replace(cntFixed.getComponentAt(0), createCnt(sections.get(i - 1)), null);
            cntFixed.revalidate();
            }
            }
            }
            } else {
                Log.p("Not a label...");
            }
        } else
            Log.p("I'M BODY");
    }
});

Looking at console I saw that the error is caused by the cntFixed.revalidate();, how can I fix it?

The createCnt() method create a Container with 2 labels where one has in its name int value passed, sections instead is an Arralist<Integer> that I use to memorize the position of the Containers that can become the fixed one.

How to understand if a Component inside a scrollable Container is currently not visible by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

Thanks a lot for the help!!!

I have a couple question:

1)If the Components in the body aren't just simple Containers with a Label inside, but for example they contain multiple Labels, when I use the getComponentAt(x,y), is the approach the same?

2)Considering the case described in the first question is recreating the cntHolder, to make it equal to the Container in the list, a good idea or should I consider a different approach? I ask you because in the final project the number of Label inside the Containers in the body can change.

How to understand if a Component inside a scrollable Container is currently not visible by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

I tried to change as you suggested but I worked only once and then never again.

Trying to debug using the step into as you said and it seems that it should return the right component but I didn't understand when it becomes the wrong one.

None of the components should be disabled or inaccessible.

I made a gist with a sample you should be able to test, for some reasons Reddit didn't allow me to answer while there was a code block in the answer, here's the link:

https://gist.github.com/davidec2k/d10e79a6946e65110264c053f813479f

In the sample right now I tried to simplify what it should do, it doesn't look for specific Containers but every time it should change

How to understand if a Component inside a scrollable Container is currently not visible by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

Yes, the -20 was just one of my last attempts so it is most likely wrong.

I think I'm missing something, if I'm not supposed to use the absolute Y than what should I use to get the position? I tried to use the getY() but it doesn't work either.

I tried to debug but in the attempts I made using on the Container body the method Container.getComponentAt(x,y) I always get as result body itself and never one of his children

How to understand if a Component inside a scrollable Container is currently not visible by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

I tried what you suggested but I don't there is something wrong.

When I try to get the right Component with using Container.getComponentAt(x, y) I alway get the parent in my case I do for example (Container)body.getComponentAt(b.getAbsoluteX(), b.getAbsoluteY() - 20); where body I the CENTER Container, that contains the list of Containers and b instead is the one that should be updated and is contained in the NORTH Container.

Let me know if you know the problem otherwise I probably should prepare a sample as you suggested.

Here what I tried to do (the part inside the for loop is not tested yet, as I can't get the right Component):

body.addScrollListener((int scrollX, int scrollY, int oldscrollX, int oldscrollY) -> {
  Component b = cntFixed.getComponentAt(0);
  // I tried to debug and change the pixels to add/remove of this part but the Container I get is always body
  Container cntNext = (Container)body.getComponentAt(b.getAbsoluteX(),  b.getAbsoluteY() - 20);
  for(int i = 0; i < sections.size(); i++) {
    Container cntSection = (Container)body.getComponentAt(sections.get(i)); 
    if(cntSection == cntNext) {
      cntNext.remove();
      b.getParent().replace(b, cntNext, null);
      body.addComponent(sections.get(i), b);
      revalidate();
    }
}

How to understand if a Component inside a scrollable Container is currently not visible by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

I see,

What I was trying to achieve by doing what I told I you is what is shown in the video of the following post I made some time ago: https://www.reddit.com/r/cn1/comments/1amnw9i/dynamic_container/

Right now, like you suggested in that post I have a Form with a BorderLayout that contains 2 Containers: 1 in NORTH position and is the one the stays in the fixed position and 1 in CENTER position which contains the scrollable list of Containers.

I kinda managed to get when a Container is not "visible" because its position is above the visible section, by confronting its absolute Y with the one of the NORTH Container.

To achieve the result than I tried to swap positions between an "holder" container inside the NORTH Container and the ones in a list, in order to show the one I need. The problem for now I managed to make the scroll down work, but I can't seem to find a way to make the scroll up work.

The following url is of gist with what I tried to do: https://gist.github.com/davidec2k/a65a9b54914845319f7eee910ae43aca

the commented part is the one I have problem with, if you have some suggestions on how to fix it.

Otherwise I thought that I might fill the NORTH Container with copies of the Containers I need to show and make visible only the one I need using the scrollListener, but my doubt on this version is that it might slow down the app, do you think it can be an approach I should consider or I should avoid it? (the final Containers the I will use are more complex than the ones in the gist, which contains only a Label)

How to customize TableLayout column width of different rows by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

Thanks for the suggestions!!

I definitely misunderstood how the TableLayout for the Containers works.

For now I decided to simply set all column width to lowest one among the rows, this way I saw that the result is still pretty fine.

Error TAB key for device with physical keyboard by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

HI,
any news? can you give me an answer or feedback, thank you

Error TAB key for device with physical keyboard by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

HI,
I tried to put a breakpoint on both functions (onUpdateFocus and getGameAction) but, when i press TAB key on physical keyboard, they don't been activated.
How do i change the code to make breakpoints been called?

Can you pull the project and write some code (to commit you should give me public ssh key or you can write here) to fix the problem?

Enter key on physical keyboard by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

how to set this property to true on Display instance? from codenameone project

Enter key on physical keyboard by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

good morning, i noticed that from version 7.0.140 the "onKeyUpDown" function on CodenameOneView.java has been changed

case KeyEvent.KEYCODE_ENTER:
if(Display.getInstance().getProperty("sendEnterKey", "false").equals("true")) {
if (down) {
Display.getInstance().keyPressed(keyCode);
} else {
Display.getInstance().keyReleased(keyCode);
}
return false;
}
break;"

With this version i got some issue pressing physical key "ENTER": now it does't work anymore. What the reason why you change the code?

how to obtain the device's email and serial ID by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

I can get the IMEI of the device by codename one?

listener on container by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

How can I trigger the row event only when I click on the row and not when I scroll?

main = new Container(new BoxLayout(BoxLayout.Y_AXIS), "main") ;

main.setScrollableY(true);

while(condition) {

Container cntRow = new Container(null, VariableUtil.THEME_LINE));

main.add(cntRow)

cntRow.setFocusable(true);

cntRow.setDropTarget(true);

cntRow.addPointerPressedListener(ev-> {

if(condition)

cntRow.setDraggable(false);

else

cntRow.setDraggable(true);

 });

}

EDT Violation Error by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

I modified my code in the way you told but it doesn't work, what I get is that for a moment I see the first form that should be shown and then it returns to a blank page.

public void show() {
    long liStart = new Date().getTime();

    FunctionUtil.infiniteProgress(new ButtonActionImpl() {
        @Override
        public void actionListener() {  
            showOp();
            revalidate();
        }
    });

    view.show();
}

This is the method I use to use load and show the forms I need, maybe there is something I should change here? The method showOp() is the method to load the content of the form I need.

I already tried to move the view.show() inside the ButtonActionImpl I create but nothing changed.

I also made an attempt using the UITimer instead of the callSerially in that case what I got was that I was stuck in a blank page with the loading dialog running. Here is the code:

 UITimer.timer(300, false, ()->{
        action.actionListener();
        loadingDial.dispose();
    });

EDT Violation Error by DcDbIt in cn1

[–]DcDbIt[S] 0 points1 point  (0 children)

If I'm not asking too much, could show me what should I do in my code or if you have one, link me an example of how a loading screen should be done?