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/27a6806b-0ad3-41bd-bb45-5082cb69c9aan%40googlegroups.com.

Reply via email to