Hightlight image within a vertical manager - blackberry

So i have 3 images in a vertical field manager and each image is clickable and proceeds to the correct url. all that works. the only problem at this time is that when i scroll (up or down), i don't know which image is currently focused. i don't know until the browser opens the corresponding url.
so is there any way to get a border or a highlight to appear under my images (or within the manager) so that i can definitely see which image is currently focused? so if you think of a list, your selections are highlighted as you scroll up and down. i want something similar to that with my application.
thank you for your help.
ac

using the setSpace(int,int) method on the bitmap field worked great. this allowed me to see a border around the element that had focus.

override inline the bitmapfield drawFocus method. Something like this
protected void drawFocus(Graphics graphics, boolean on){
graphics.setBackgroundColor(0x00204020);
graphics.drawRect(0, 0, getBitmapWidth(), getBitmapHeight());
}

Related

How to add an clickable button on top of a MapView in Delphi FireMonkey?

I need to add a clickable button with a custom image on top of the TMapView, is this possible?
ps: even if I leave the TImage on top of the view, the map overlays it, that is, the button appears quickly until the map rendering overlays it...
edit ps2: There is no code for the example, I simply put a TImage on the Form, either as a child of TMapView, or as a child of TForm, when I test it on android, when opening the app the image appears quickly before the map and then when the map starts to appear it overlays the image...
edit ps3: I don't know if a TImage is the correct way to do this, is this any component to leave on top of the map, that keeps showing up, serving as a button? Just like on Google Maps...
You can't show anything on TMapView because of "z-order" problem. I looked for while to find a solution.
See : Delphi object over TMapView

Set prompt text to the center of TextArea control in JavaFX

I was wondering if there is a way to set prompt text location in TextArea.
Basically I am trying to create the similar effect as ListView Placeholder does. It is just to keep consistency in UI, so that everything mostly would look similar.
Any suggestions with this.
I think you can only do this by a dirty hack:
Set alignment to center.
Depending on your desired behavior either add a focus listener which sets the alignment to left again when focused and back to center when focus left.
text.focusedProperty().addListener((p,o,n)->{
if(n){
text.setAlignment(Pos.CENTER_LEFT);
}else {
text.setAlignment(Pos.CENTER);
}
});
Or add a keylistener to get the left aligned text while typing(and a focus-left listener to reset it if needed, eg. empty)
setOnKeyPressed(e->text.setAlignment(Pos.CENTER_LEFT));

Blackberry PictureScrollField image issue when focus is removed

I'm using a PictureScrollField in a VerticalFieldManager with other fields that need focus. When the PictureScrollField receives focus, the images are shown in their original form. But when I remove focus, by default, the field draws a white square over the images. I looked around in the API and couldn't find a way to undo this default property. How to remove these squares?
This is the image when the field has focus-
And this is when the field loses focus-
You can see how the images have white overlays which look bad for non rectangular transparent images.
The solution is pretty simple - override onUnfocus method as
protected void onUnfocus(){
/*do nothing to prevent BB default image highlight*/
/*or do your own thing*/
}

Blackberry - Smileys in text field

I'm looking for a way to insert emoticons/smileys/any bitmap in a text field (LabelField, EditField, whatever). From what I've researched so far, there is no direct way to do this, so I'm stuck with trying to simulate this behavior.
I was thinking of using a normal text field and instead of smileys to insert blank spaces and then place some BitmapFields over the text field where the smileys should be. The problem is that I have no reliable/quick way of finding a character's position on screen (x,y).
Can you give me some ideas?
Can you think of other approaches to this problem?
I'm sure a lot of people encountered this kind of problem at one time or another. I hope there is someone who managed to find a solution. I'm desperate enough to accept any solution, no matter how crazy/complex/difficult.
Also, I would like to use this in SDK 5.0 and up, but I will settle for only 6.0.
What you might be able to do is create a custom Manager that is a container for EditFields and BitmapFields. When the user clicks in the initial EditField that is inside of your Manager and begins typing, you let them type until they want an emoticon. When they select it you create a BitmapField right after the EditField and then place a new EditField to the right of the BitmapField. You'll have to keep track of things like when the user hits backspace and empties an EditField, it should be removed, and then they are selecting the BitmapField, and a subsequent backspace would delete the BitmapField and put focus on the previous EditField.
You will have to also create your own EditField that you can control the size of, and BitmapField that allows for backspace to delete it.
As far as I can think ahead, you shouldn't have any problem using this for 5.0
Edit for comments:
You'll have to be implementing your own sublayout() of your Manager in any approach you take, so you know positions because you're the one who put them there. If you want to want to do multi-line (my approach was for single-line), you can do one of three things:
1.) Just have new EditFields for each line and do the linking the same way I talked about where backspace drops you to the previous Field, in this case the last line. You have to keep measurements of how big the field is based off of the text, and see if that will move it to the next line. If it does just adjust where the EditFields are positioned.
2.) You can do your image placement in the multi-line field by implementing your own EditField that expands height, in which case you'll know where the text is and what lines you are on. Drawing the Bitmap would be a matter of calculating (what line number you are) * (font height) and getAdvance(text_up_to_bitmap).
3.) Implement your own EditField where you have a focusable Manager that you manually do all of the drawing. You can parse a String that you save from capturing key strokes and maybe have a flag where an emoticon should be. Draw the text before it, draw the emoticon, then continue drawing the text. The difficulty with this is you will have to do things like determining where the cursor should be, bringing up the virtual keyboard, and handling some of the other tasks that the EditField does for you.

Check out whether or not Focus Rect is required (Delphi)

Imagine that we have a form with two buttons on it. I run the application and I click on the first button. nothing happens and no focus rectangle is displayed. But when I press a key, it shows a focus rect on the button and even if I click on the second one, it moves the focus rect to it. So it doesn't display the focus rect unless I press a key. I'm creating my own component and I need to know whether or not I should display the focus rect to draw it.
How do I know it?
I think it's not meant to display the focus rectangle by default, that's until a keyboard accelerator is used. Read UI State on MSDN, that suggests WM_QUERYUISTATE should be used to determine if keyboard accelerators or focus indicators should be drawn or not.

Resources