Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Developer
Posts: 47
Registered: ‎05-06-2009
My Device: Not Specified
Accepted Solution

Prevent a Dialog.ask from beeing scrolled down on launch

[ Edited ]

Hi there!

 

I want to show an EULA (very long String) in a Dialog.ask, but it is scrolled down to the buttons when launched. Is there a simple way to prevent it which I can't find?

 

Thank you!

Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Prevent a Dialog.ask from beeing scrolled down on launch

only focusable components allow scrolling.

 

i had a similar issue while displaying an EULA. on top it was very long and the formatting was complex.

i opted for including the EULA in html format.

in my UI i show accept, decline and show buttons.

the show button opens the html in the browser - with all the formatting automatically done.

 

nobody reads the eula anyhow, and letting the user scroll through miles of text if he doesn't intend to read it is bad design.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 47
Registered: ‎05-06-2009
My Device: Not Specified

Re: Prevent a Dialog.ask from beeing scrolled down on launch

I'm also not a friend of it but I think I have to ensure the user "reads" the text although he will probably only scroll all the way down. Thats probably why the BB Messenger and other things have it done that way.

 

I doubt that the html-thing is completely correct!

Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Prevent a Dialog.ask from beeing scrolled down on launch

well, it was approved by the legal staff of my customer (a company with a few 10k employees).

 

if you want to do otherwise you have to write yourself a field that scrolls a large amount of text without it being editable. i don't think one of the pre-made fields can do this, you'll have to overwrite navigationmovement and provide means of scrolling yourself.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 455
Registered: ‎01-14-2009
My Device: Apple iPhone 3GS 16GB

Re: Prevent a Dialog.ask from beeing scrolled down on launch

try this

 

 

 
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import java.io.*;
import net.rim.device.api.system.Bitmap;

import java.io.InputStream;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;

public class LicenseForm extends MainScreen
{
        public static LicenseForm getInstance()
        {
                if(instance == null)
                        instance = new LicenseForm();

                return instance;
        }
        public LicenseForm()
        {
                VerticalFieldManager verticalFieldManager  = new
                VerticalFieldManager (VerticalFieldManager.USE_ALL_WIDTH |
                                VerticalFieldManager .USE_ALL_HEIGHT)
                {   
                        public void paint(Graphics graphics)
                        {
                                graphics.setBackgroundColor(Color.BLACK);
                                graphics.clear();
                                graphics.setColor(Color.WHITE);
                                super.paint(graphics);
                        }
                };
                acceptCmd = new MenuItem("Accept", 0x186a0, 100) {

                        public void run()
                        {
                                ApplicationSettings.getInstance().setLicenseConfirm("True");
                                try
                                {
                                        popScreen(LicenseForm.this);
                                }
                                catch(Exception e) 
                                {
                                        ExceptionHandler.handle(e.toString());
                                }
                               //CONTINUE EXECUTIO
                        }

                };
                denyCmd = new MenuItem("Deny", 0x18a88, 101) {

                        public void run()
                        {
                                try     
                                {      Tools.shutDownApp();
                                }catch(Exception e)
                                {
                                        ExceptionHandler.handle("ERROR IN Deny"+e.toString());
                                }

                        }

                }
                ;

                RichTextField rF= new RichTextField ("My App",RichTextField.NON_FOCUSABLE )
                {
                        public void paint(Graphics graphics)
                        {      
                                Constants.getInstance().setTitleTheme(graphics);
                                super.paint(graphics);
                        } 
                };    
                rF.setFont(Constants.getInstance().getTitleFont());
                setTitle(rF);        
                InputStream is = getClass().getResourceAsStream("/LicenseAgreement.txt");
                StringBuffer buff = new StringBuffer();
                int ch;
                try
                {
                        while((ch = is.read()) != -1) 
                                buff.append((char)ch);
                }
                catch(Exception e) { }
                verticalFieldManager.add(new RichTextField(buff.toString()));
                add(verticalFieldManager);
        }

        public void makeMenu(Menu menu, int instance)
        {
                menu.add(acceptCmd);
                menu.add(denyCmd);
        }

        private MenuItem acceptCmd;
        private MenuItem denyCmd;
        private static LicenseForm instance;
}

 

 

Developer
Posts: 47
Registered: ‎05-06-2009
My Device: Not Specified

Re: Prevent a Dialog.ask from beeing scrolled down on launch

[ Edited ]

 

They will know that better than me Smiley Wink

Anyway, this is how it can be achieved (mashup from some other samples):

 

 

public final class LicenseDialog extends Dialog
{
	public LicenseDialog()
	{
		super(Dialog.D_YES_NO, "%title%", Dialog.NO, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Dialog.VERTICAL_SCROLLBAR);
		
		RichTextField eula = new RichTextField (%license%);
		
		Manager delegate = getDelegate();
		if( delegate instanceof DialogFieldManager)
		{
			DialogFieldManager dfm = (DialogFieldManager)delegate;
			net.rim.device.api.ui.Manager manager = dfm.getCustomManager();
			if(manager != null)
			{
				manager.insert(eula, 0);
			}
		}
	}
}

//EDIT:

Or the code above this post Smiley Wink