I mean the rectangle that the showPopupDialog method wants as a parameter.
That method simply does not work with certain values, like for example:
x = 1024 y = 767 size = width = 1534 height = 27
?
Notice that this applies to both InteractionDialogs and Dialogs, with or
without a BrowserComponent inside.
Even in this simple Dialog it does not work when I want to enlarge it
horizontally.
//this method yields a centered rectangle
private static Rectangle getRect(Container c)
{
Rectangle r=new Rectangle();
Dimension d=new Dimension();
int w=Display.getInstance().getDisplayWidth();
int h=Display.getInstance().getDisplayHeight();
d.setWidth(c.getWidth());
d.setHeight(c.getHeight());
r.setWidth(c.getWidth());
r.setHeight(c.getHeight());
r.setX(w/2-d.getWidth()/2);
r.setY(h/2-d.getHeight()/2);
return r;
}
//this method opens the dialog
public static void testAlertDialog(String s1, String s2,int width)
{
Dialog alertDialog=new Dialog(s1);
alertDialog.setDisposeWhenPointerOutOfBounds(true);
Button okButton=new Button(okCommand);
alertDialog.setLayout(BoxLayout.y());
Container c1=new Container();
c1.setLayout(BoxLayout.y());
Command backCommand=new Command("Back") {
@Override
public void actionPerformed(ActionEvent evt) {
alertDialog.dispose();
}
};
alertDialog.setBackCommand(backCommand);
c1.add(okButton);
Rectangle rect = new Rectangle(getRect(c1));
if (width>rect.getWidth()) rect.setWidth(width);
alertDialog.setSize(new Dimension(rect.getWidth(),rect.getHeight()));
c1.setSize(new Dimension(rect.getWidth(),rect.getHeight()));
alertDialog.add(c1);
Rectangle dialogRect=getRect(c1);
alertDialog.showPopupDialog(dialogRect);
}
Il giorno venerdì 18 dicembre 2020 alle 05:56:43 UTC+1 Shai Almog ha
scritto:
> Which rectangle?
> How?
>
> On Thursday, December 17, 2020 at 11:24:31 AM UTC+2 P5music wrote:
>
>>
>> No, I meant I set the rectangle, so it has to overwrite any preferred
>> size.
>> That InteractionDialog seemed to be missing dimensions and coordinates
>> until I set them with the showPopupDialog(rect) method.
>> But
>> when I set them, it refuses to adopt that dimensions
>> because it turns up having a strong preferred size it wants to stick to.
>> Regards
>> Il giorno giovedì 17 dicembre 2020 alle 04:33:35 UTC+1 Shai Almog ha
>> scritto:
>>
>>> What's pocking a value into the preferred size?
>>>
>>> On Wednesday, December 16, 2020 at 11:16:13 AM UTC+2 P5music wrote:
>>>
>>>> Use cases won't work if components do strange things.
>>>> I had to use the showPopupDialog(rect) method because the
>>>> InteractionDialog is not able to show itself with the right size. Ok.
>>>> Now it seems that it will stick to its preferred size whatever value I
>>>> poke into it, and by the way that value is also wrong because it appears
>>>> in
>>>> a center-right-ish position.
>>>>
>>>> Il giorno mercoledì 16 dicembre 2020 alle 04:44:10 UTC+1 Shai Almog ha
>>>> scritto:
>>>>
>>>>> Place a breakpoint in the method and look at the preferred size of the
>>>>> preferred size of the dialog before you show it. I'm guessing it will be
>>>>> small.
>>>>> Showing a browser component in a dialog isn't a use case we ever
>>>>> intended so I doubt this will work.
>>>>>
>>>>> On Tuesday, December 15, 2020 at 10:38:15 AM UTC+2 P5music wrote:
>>>>>
>>>>>> As I said the measurement is OK, that is, I have the right
>>>>>> dimensions. Also in the debugging I see the correct values, but it is
>>>>>> the
>>>>>> InteractionDialog that does not resize accordingly. Can you check my
>>>>>> code
>>>>>> as to the size change of the InteractionDialog? All is done after the
>>>>>> page
>>>>>> loading, so it is why the measurements are right but it does not resize.
>>>>>> Thanks
>>>>>>
>>>>>> Il giorno martedì 15 dicembre 2020 alle 05:15:26 UTC+1 Shai Almog ha
>>>>>> scritto:
>>>>>>
>>>>>>> Are you placing a BrowserComponent in an interaction dialog?
>>>>>>> That's no a great idea.
>>>>>>>
>>>>>>> BrowserComponent doesn't know its size since it didn't load the HTML
>>>>>>> yet and does it asynchronously. You need to determine the size for it
>>>>>>> not
>>>>>>> the other way around.
>>>>>>>
>>>>>>> On Monday, December 14, 2020 at 10:57:09 AM UTC+2 P5music wrote:
>>>>>>>
>>>>>>>> I had to change the user experience of one form in my app because I
>>>>>>>> couldn't have both a TextArea and a BrowserComponent to have the "fill
>>>>>>>> parent" behaviour.
>>>>>>>> I decided to display the webview in an alert dialog.
>>>>>>>> The width of the webview has to be as large as the lesser dimension
>>>>>>>> of screen, that is passed as the width parameter, for example the
>>>>>>>> skin I
>>>>>>>> am testing onto has 1534 (it is the height in landscape mode).
>>>>>>>> Also the height of the dialog is calculated to be as large as to
>>>>>>>> display a button and the webview.
>>>>>>>>
>>>>>>>> But I get the tiny dialog that can be seen in the attached image.
>>>>>>>>
>>>>>>>> How can this be fixed sticking with InteractionDialog?
>>>>>>>>
>>>>>>>> Notice that the rectangle has right dimensions, as expected to be
>>>>>>>> in the user interface:
>>>>>>>> x = 983 y = 729 size = width = 1534 height = 104 (debug values)
>>>>>>>> but the dialog does not spread.
>>>>>>>> In the code below there are some utility methods that work
>>>>>>>> seamlessly with other dialogs, to set the correct appearance. Just
>>>>>>>> this
>>>>>>>> dialog is not working.
>>>>>>>>
>>>>>>>> Thanks in advance
>>>>>>>>
>>>>>>>> public static void testWebViewAlertDialog( String s1, String s2,int
>>>>>>>> width)
>>>>>>>> {
>>>>>>>> InteractionDialog alertDialog=new InteractionDialog(s1);
>>>>>>>> Button okButton=new Button(R.okCommand);
>>>>>>>> alertDialog.setLayout(BoxLayout.y());
>>>>>>>> Container c1=new Container();
>>>>>>>> c1.setLayout(BoxLayout.y());
>>>>>>>>
>>>>>>>> okButton.addActionListener(new ActionListener() {
>>>>>>>> @Override
>>>>>>>> public void actionPerformed(ActionEvent evt) {
>>>>>>>> alertDialog.dispose();
>>>>>>>> }
>>>>>>>> });
>>>>>>>> c1.setLayout(new BorderLayout());
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> BrowserComponent testWebView=new BrowserComponent();
>>>>>>>>
>>>>>>>>
>>>>>>>> testWebView.addWebEventListener("onLoad", new ActionListener() {
>>>>>>>> @Override
>>>>>>>> public void actionPerformed(ActionEvent evt) {
>>>>>>>> System.out.println("onload test");
>>>>>>>>
>>>>>>>>
>>>>>>>> c1.add(BorderLayout.SOUTH,okButton);
>>>>>>>> alertDialog.add(c1);
>>>>>>>> Rectangle rect = getRect(c1);
>>>>>>>> c1.add(BorderLayout.CENTER,testWebView);
>>>>>>>> if (width>rect.getWidth()) rect.setWidth(width);
>>>>>>>>
>>>>>>>> rect.setHeight(rect.getHeight()+testWebView.getPreferredSize().getHeight());
>>>>>>>> alertDialog.showPopupDialog(rect);
>>>>>>>> }});
>>>>>>>> testWebView.setPage(s2,"");
>>>>>>>>
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>
--
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/9d51903a-247b-4188-91e5-7c7378041813n%40googlegroups.com.