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
New Contributor
Posts: 8
Registered: ‎07-10-2012
My Device: torch 9860
My Carrier: Idea
Accepted Solution

componentcanvas is not drawing components on top of other fields

hello,

I am trying to use ComponentCanvas  to make a button on top of video field.

but it is not drawing field on top of it.

It is adding componentcanvas field first and then adding  videofield ;  behaves like verticalfield manager.

so can any one give me proper way to use componentcanvas as I couldn't find any proper docs to use it.

 

thanks. 

Developer
Posts: 19,624
Registered: ‎07-14-2008
My Device: Not Specified

Re: componentcanvas is not drawing components on top of other fields

Here are the docs for OS 7.1.  :

 

http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/ui/container/ComponentCanvas.h...

 

From a review of your problem description, are you actually adding the video field to the ComponentCanvas?

 

There are a few Threads that talk about ComponentCanvas, I recommend that you review these. 

New Contributor
Posts: 8
Registered: ‎07-10-2012
My Device: torch 9860
My Carrier: Idea

Re: componentcanvas is not drawing components on top of other fields

[ Edited ]

Thanks peter_strange for your reply:

But I need example for using the componentcanvas.

 

i tried one of the demo example provided by RIM.

 

i found one code sample but it is not working for me as well.

 

 if(_cameraField != null)
        {
            // Add the camera field to a new ComponentCanvas
            ComponentCanvas compCanvas = new ComponentCanvas(Display.getWidth(), Display.getHeight());
            compCanvas.add(_cameraField, 0, 0);

            // Initialize GLField 
//            _glField = new DemoGLField(GL_FIELD_WIDTH, GL_FIELD_HEIGHT);
//            _glField.setTargetFrameRate(GL_FRAME_RATE);
            
            // Add the GLField to the canvas
             abc=new RichTextField("karan Dubal");
            compCanvas.add(abc, 100, 100);
            
            // Add the ComponentCanvas to the screen
            add(compCanvas);
        }

  here glfield is commented which is in original RIM's Demo app and it is working fine but when i tried to put my own field like buttonfield/labelfield or richtextfield it is not working. camera field is  overlapping other fields and richtextfield cannot be viewed.

New Contributor
Posts: 8
Registered: ‎07-10-2012
My Device: torch 9860
My Carrier: Idea

Re: componentcanvas is not drawing components on top of other fields

I figure out the how to overlap buttonfield on camerafield.

 

I used ViewFinderOverlay for this purpose.

 

here is the code that i used:

if(_cameraField != null)
        {
            
        		try{
        		overlay= new ViewfinderOverlay(_cameraField);//used viewfinderoverlay
    			overlay.getCanvas().add(new ButtonField("KD"));
    			add(overlay);
    			}
        		catch(Exception e){
        		final	String msg=""+e;
        			Application.getApplication().invokeLater(new Runnable() {
						
						public void run() {
							// TODO Auto-generated method stub
						Dialog.alert(msg);	
						}
					});
        		}
}
        else
        {
            add(new RichTextField("Error connecting to camera"));
        }