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 Developer
Posts: 4
Registered: ‎08-06-2008
My Device: Not Specified

How to design a button or picture inside text

Hi,

 

I want to include one picture inside a text and have one "hyperlink" that opens a new screen or popup.

 

Now, I m searching a method to design the following content with the Eclipse plugin and JDE env. 4.1

 

Problem explanation 

  •  Is it a way to do this ? Can I do this with Vertical/HorizontalFieldManager? Or should I design the all with Graphics?
  • About the hyperlink, should I use a ButtonField or something else? Should I separate the entier text in two RichTextField?

Many thanks in advance for your help!
Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to design a button or picture inside text

i think it would be best to create a custom field. calculate the number of lines you need and set the extend accordingly.
draw the bitmap and the text using graphics.draw with the x for the text = bitmap.getWidth +5 until y reaches the height of the bitmap.
----------------------------------------------------------
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
New Developer
Posts: 4
Registered: ‎08-06-2008
My Device: Not Specified

Re: How to design a button or picture inside text

Okay, thanks for the response! I'll try it in a later stage.

 

What about the "hyperlink" solution?

BlackBerry Development Advisor
Posts: 15,753
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: How to design a button or picture inside text

The ActiveRichTextField and ActiveAutoTextEditField classes provide string pattern matching.  Meaning they can automatically highlight active regions such as URLs and phone numbers that a user can click on and open.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 4
Registered: ‎08-06-2008
My Device: Not Specified

Re: How to design a button or picture inside text

Thanks a lot MSohm, exactly what I searched !

 

Back to ma first question: To realize "picture in text" design, is the Graphic.draw method really the only one ?!? No other solutions via Manager or something else?

BlackBerry Development Advisor
Posts: 15,753
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: How to design a button or picture inside text

The only way I can see to do this with the existing managers would be to break your text up into two parts.  The part to the right of the image could be drawn in one field and the text under it in another.

 

To do this you would start with a VerticalFieldManager (call vfmBack).  Then create a HorizontalFieldManager and add a BitmapField and some type of text field to it.  Then add the HorizontalFieldManager to vfmBack and add a second text field to vmfBack that would be shown under the top two fields.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 4
Registered: ‎08-06-2008
My Device: Not Specified

Re: How to design a button or picture inside text

I cannot find out a way to get one specific text (ex: blablablabla) into an ActiveAutoTextEditFiel...

 

The javadoc explains how to add a new data types:

  1. Extend a StringPattern and add it to the StringPatternRepository.
  2. Create an object describing the new data that implements the ActiveFieldCookie interface
  3. Create a Factory for this new object, add the factory to the RuntimeStore with an appropriate Long ID (GUID).
  4. When a string region matches your data set, fill out the appropriate fields inside the Match class. Set the Match.id field to the GUID of the factory.
  5. When the cursor is over the region matcing your data set as described above, the system will pass an ActiveFieldContext instance that contains the String region into your Factory. Use this String to initialize your object.
 Can you please provide me a code example of this?
BlackBerry Development Advisor
Posts: 15,753
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: How to design a button or picture inside text

Have a look right here:

 

How to - Leverage pattern matching in BlackBerry smartphone applications to provide an integrated user experience
Article Number: DB-00525

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 27
Registered: ‎11-18-2008
My Device: Not Specified

Re: How to design a button or picture inside text

Hi,

 

I am having a similar issue. I have read the article that Mark listed and it had a great working example that literally did exactly what I would have wanted, only in my case I want to redirect on phone numbers. I modelled my application to use the ActiveFieldCookie and Factory approach. Now I am finding that my StringPattern implementation is working it catches an appropriate match but unlike the sample application the ActiveFieldCookie implementation is not firing the getFocusVerbs method, which returns an instance to my menuitem. Now I am pretty new with BB development, the only conclusion I have come to is perhaps because my application is designed with an alternate entry point that perhaps the code isn't being loaded into the device the same as a single stand alone background application (which the example was). I am really looking for some guidance on this. I am currently testing this on the default simulator that comes packaged with JDE v4.0.2.

 

Thanks,

BlackBerry Development Advisor
Posts: 15,753
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: How to design a button or picture inside text

Can you post the code for your main method that is handling the alternate entry point?  Does your application remain running in the background or do you exit the application?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker