If I put

        backgroundInteractionDialogRect.setX(0);
        backgroundInteractionDialogRect.setY(0);
        backgroundInteractionDialogRect.setWidth(0);
        backgroundInteractionDialogRect.setHeight(0);
        
backgroundInteractionDialog.showPopupDialog(backgroundInteractionDialogRect);

I get a tiny rectangle in the top-left corner, not useful.

If I put
        int w=Display.getInstance().getDisplayWidth();
        int h=Display.getInstance().getDisplayHeight();

        backgroundInteractionDialogRect.setX(0);
        backgroundInteractionDialogRect.setY(0);
        backgroundInteractionDialogRect.setWidth(w);
        backgroundInteractionDialogRect.setHeight(h);
        
backgroundInteractionDialog.showPopupDialog(backgroundInteractionDialogRect);

I get this exception:

java.lang.IllegalArgumentException: margin cannot be negative
at com.codename1.ui.plaf.Style.setMargin(Style.java:2405)
at com.codename1.ui.plaf.Style.setMargin(Style.java:2383)
at com.codename1.ui.plaf.Style.setMargin(Style.java:1425)
at 
com.codename1.components.InteractionDialog.show(InteractionDialog.java:346)
at 
com.codename1.components.InteractionDialog.showPopupDialog(InteractionDialog.java:807)

If I use other values I get a tiny rectangle with some horizontal 
positioning but very similar to the first one.
What's wrong?


Il giorno giovedì 31 dicembre 2020 alle 03:25:09 UTC+1 Shai Almog ha 
scritto:

> I was wrong. There's a better way to do this. 
>
> The native OS code for handling events in Codename One checks first to see 
> if there's a component on top. 
> You can just create.a transparent (or translucent) interaction dialog and 
> show it on 0, 0, 0, 0. This way it will cover the entire screen. Then you 
> can show another dialog on top of that. 
>
> You can even add a button to the transparent dialog and it will grab all 
> pointer events so you know if a user clicked outside and you could dispose 
> both dialogs. You then don't need the pointer listeners etc.
> On Thursday, December 31, 2020 at 12:08:48 AM UTC+2 P5music wrote:
>
>> The function isMouseEventOutside() was wrong. Now I fixed it.
>>
>> Il giorno mercoledì 30 dicembre 2020 alle 09:44:54 UTC+1 P5music ha 
>> scritto:
>>
>>> Ok, preventing the BC's from processing the events should not be 
>>> difficult.
>>> But the strange thing is that the right container in the table layout 
>>> does not receive the events like the left one (except the small BC). And so 
>>> happens to the FAB.
>>> For example, if I click on a button in the left container the dialog 
>>> goes away, whilst if I click on a button of the right container nothing 
>>> happens.
>>> (the left container is bound to the FAB, and the FAB is insensitive too)
>>> Maybe unbinding the left container from FAB would lead to the entire 
>>> layout being insensitive to mouse events? Or something similar? Would it be 
>>> a possible workaround?
>>> Regards
>>> Il giorno mercoledì 30 dicembre 2020 alle 05:09:14 UTC+1 Shai Almog ha 
>>> scritto:
>>>
>>>> Sorry about that. I forgot your app is mostly HTML. That's problematic 
>>>> as we don't have the same amount of control over native as we do over our 
>>>> code. 
>>>> The reason is simple. All events go through the parent form and the 
>>>> previous code works well for our components.
>>>>
>>>> But the HTML rendering runs in the native OS thread and so do their 
>>>> events. So the event needs to be processed there and can't be intercepted. 
>>>> The only workaround is to write JavaScript code that will disable the 
>>>> browser component explicitly. 
>>>>
>>>> On Tuesday, December 29, 2020 at 12:19:51 PM UTC+2 P5music wrote:
>>>>
>>>>> Please have a look to this code snippet. I added it to the 
>>>>> CommandDialog:
>>>>>
>>>>> private void setMouseEventsListener()
>>>>> {
>>>>> actionListener=new ActionListener() {
>>>>> @Override
>>>>> public void actionPerformed(ActionEvent evt) {
>>>>>
>>>>> if (isMouseEventOutside(evt.getX(),evt.getY())) evt.consume();
>>>>>
>>>>> }
>>>>> };
>>>>> form.addPointerDraggedListener(actionListener);
>>>>> form.addPointerPressedListener(actionListener);
>>>>> form.addPointerReleasedListener(actionListener);
>>>>> form.addLongPressListener(actionListener);
>>>>>
>>>>> }
>>>>>
>>>>> It is not working as expected.
>>>>> I can report this:
>>>>>
>>>>> The layout is a table layout for a master/detail appearance.
>>>>> In the left part there are some buttons and a large BrowserComponent.
>>>>> In the right part there are some buttons and a small BrowserComponent.
>>>>>
>>>>> Let's say a CommandDialog is called from the left container from a 
>>>>> callback of the Javascript interface of the BrowserComponent when I long 
>>>>> press an iFrame element.
>>>>>
>>>>> The dialog appears.
>>>>> -If I click inside the dialog, the mouse event is not processed. The 
>>>>> dialog buttons do not work. (not OK)
>>>>> -If I click outside:
>>>>>             -if I click on the right container of the table layout 
>>>>> nothing happens (OK)
>>>>>             -if I click on the left container:
>>>>>                           -if I click on a button the dialog disappear 
>>>>> (OK but I will have to handle the behaviour according to a parameter)
>>>>>                           -if I click on the BrowserComponent the 
>>>>> mouse event reaches to it  (not OK)
>>>>>                                  and
>>>>>                                  the dialog does not disappears (OK)
>>>>>                                  and
>>>>>                                  the click is processed and the right 
>>>>> part changes with the detail data (not OK).
>>>>>
>>>>> What's the explanation and solution?
>>>>> Thanks
>>>>>          
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Il giorno martedì 29 dicembre 2020 alle 04:08:07 UTC+1 Shai Almog ha 
>>>>> scritto:
>>>>>
>>>>>> Hi,
>>>>>> these methods are methods ofcomponent not form so they're designed 
>>>>>> for a component to grab events in a hierarchy. It appears in form 
>>>>>> because 
>>>>>> of its hierarchy.
>>>>>> You can implement a pointer pressed/released/dragged listener and 
>>>>>> consume() all events that are out of bounds.
>>>>>>
>>>>>> On Monday, December 28, 2020 at 11:22:33 AM UTC+2 P5music wrote:
>>>>>>
>>>>>>> (Merry Christmas)
>>>>>>>
>>>>>>> My app now features a new dialog class, I called it CommandDialog. 
>>>>>>> It leverages both the features of InteractionDialog and Dialog, so the 
>>>>>>> show() method now returns a Command.
>>>>>>> This class has to be completed to be fully functional:
>>>>>>> I subclassed InteractionDialog so now I need to prevent the mouse 
>>>>>>> events from hitting the underlying components in the form.
>>>>>>> I tried 
>>>>>>>     form.setGrabsPointerEvents(false);
>>>>>>>     form.setIgnorePointerEvents(true);
>>>>>>> but they seem not to be working at all. Furthermore they seem to be 
>>>>>>> the same instruction with negated boolean parameter.
>>>>>>> Moreover I need the setDisposeWhenPointerOutOfBounds(value) feature 
>>>>>>> that also seem not to be working.
>>>>>>>
>>>>>>> I need a workaround if necessary. I have some ideas but maybe 
>>>>>>> something simple is available.
>>>>>>>
>>>>>>> This applies also to the InteractionDialog itself.
>>>>>>>
>>>>>>> Thanks in advance
>>>>>>>
>>>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/a19dba28-392a-408c-b631-748704302575n%40googlegroups.com.

Reply via email to