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
Regular Contributor
Posts: 94
Registered: ‎02-27-2010
My Device: rien
My Carrier: etudiant
Accepted Solution

edit field cursor

 


 

hi 

 Here is a code that I want to change a editfield and insert a picture on which I want to write the data

 

 

         EditField yu = new EditField("AZERTy147 ", "") {
        	        	  
        	  protected void paint(Graphics g) {
        		
        Bitmap yy =	Bitmap.getBitmapResource("inputtt.png");
             
                  g.drawBitmap(100,10, yy.getWidth(),yy.getHeight(),yy, 0, 0);
            		  g.setColor(Color.BLUE);
            		  g.drawText("azerty1474 ", 10, 0);
            		 
            
        	  
        	  public void layout( int maxWidth, int maxHeight )
	            {
	            // int width = Display.getWidth();
	            //  int height = Display.getHeight();
	                super.layout(300, 100);
	              
	                setExtent( 300, 100);
	            }
         };
         myScreen.add(new LabelField(" "));
         myScreen.add(yu) ;

 the problem, I can not find the cursor to write ??

 

 

Regular Contributor
Posts: 94
Registered: ‎02-27-2010
My Device: rien
My Carrier: etudiant

Re: edit field cursor

I want to get  this

1690i48C3ACD3211B707D

Developer
Posts: 174
Registered: ‎08-20-2008
My Device: Not Specified

Re: edit field cursor

Do you have the original png image to test with?

Regular Contributor
Posts: 94
Registered: ‎02-27-2010
My Device: rien
My Carrier: etudiant

Re: edit field cursor

yes, here is the png image

 

1691i45A6153FBFE2F86C

Regular Contributor
Posts: 94
Registered: ‎02-27-2010
My Device: rien
My Carrier: etudiant

Re: edit field cursor

is a white image, you can not s1692iB1D153BB33CBDC1Fee, right click with the mouse to click on below and save image as

Developer
Posts: 174
Registered: ‎08-20-2008
My Device: Not Specified

Re: edit field cursor

Here you go. Should work on all modern day devices but only tested on 9000 sim.

 

 

EditField yu = new EditField("AZERTy147 ", "") {
                public void paintBackground(Graphics g) {
                   Bitmap yy = Bitmap.getBitmapResource("inputtt.png");
                   g.drawBitmap(100,0, yy.getWidth(),yy.getHeight(),yy, 0, 0); 
                }
               public void layout( int maxWidth, int maxHeight )
                {
                super.layout(300, 100);
                 setExtent( 300, 100);
              }
         };

 

 

 

 

Regular Contributor
Posts: 94
Registered: ‎02-27-2010
My Device: rien
My Carrier: etudiant

Re: edit field cursor

thank you 

but how can I change the cursor position

Developer
Posts: 174
Registered: ‎08-20-2008
My Device: Not Specified

Re: edit field cursor

Do you mean in relation to the input area or the image?

Developer
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: edit field cursor

Override drawFocus method of the field to draw your own cursor.

 

There is a method to get cursor position to know where to draw it.

Regular Contributor
Posts: 94
Registered: ‎02-27-2010
My Device: rien
My Carrier: etudiant

Re: edit field cursor

give me an example or link that helps me