BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 06-19-2008, 04:58 AM   #1
mbag
New Member
 
Join Date: Dec 2007
Model: 8300
PIN: N/A
Carrier: O2
Posts: 4
Question Changing focusable property of a field?

Please Login to Remove!

Hi,

Is it possible to change whether a Field can receive the focus once it has been added to the screen?

The only place I can seem to set this is when setting the style on initial creation of the object.

Thanks.
Offline  
Old 06-19-2008, 05:36 AM   #2
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Cool

I think the only option is while defining the label...

I mean creating the new object.
Offline  
Old 06-19-2008, 06:31 AM   #3
mbag
New Member
 
Join Date: Dec 2007
Model: 8300
PIN: N/A
Carrier: O2
Posts: 4
Default

Thanks for your reply.

If anyone's interested:

The solution I've devised is to create a new Field object (and setting the style) each time I need to toggle a Field between focusable/non-focusable and use the Screen's replace() method to insert the new Field in the old Field's place. I get a reference to the old Field using Screen's getField() method.

Last edited by mbag; 06-19-2008 at 08:44 AM..
Offline  
Old 06-20-2008, 06:13 AM   #4
shraddha294
Thumbs Must Hurt
 
shraddha294's Avatar
 
Join Date: Oct 2007
Location: Hyderabad
Model: 8800
PIN: N/A
Carrier: TMobile
Posts: 111
Cool

mbag,
I wonder where would one encounter a scenario when you need a field to be focusable at one time and non-focusable at other time... after it is attached to form..
Offline  
Old 09-09-2008, 04:02 AM   #5
lanfong
New Member
 
Join Date: Jan 2008
Model: 7290
PIN: N/A
Carrier: School Project
Posts: 12
Default

It seems like I'm not the only one that encountered such problem. The solution I finally came up was overriding "isFocusable" method

Here's the note from the API Documentation

Handling focus issues
If you want your field to receive the focus, then you must override isFocusable to return true.

If you don't want your field to be focusable, you just return false.



Some people might want to make the field looks like "disabled" like what we usually do in C#, disabling textbox, label, etc so it's gray color.


What I did is overriding the paint method to make like the below code

protected void paint(Graphics graphics) {
if (!this._isFocusable)
graphics.setGlobalAlpha(50);
}

make it looks like it's disabled.....
Offline  
Old 09-09-2008, 04:35 AM   #6
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

you can exchange fields at runtime, just put another one in its place.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 09-09-2008, 06:59 AM   #7
lanfong
New Member
 
Join Date: Jan 2008
Model: 7290
PIN: N/A
Carrier: School Project
Posts: 12
Default

Quote:
Originally Posted by simon.hain View Post
you can exchange fields at runtime, just put another one in its place.
putting another one in its place. Did you mean that I created a brand new field and replace with the old one????

is it more efficient than overriding paint and isFocusable mthod??

If so, I will just create a new one then
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Honeywell 30750218-010 Memory Board picture

Honeywell 30750218-010 Memory Board

$325.00



WIFI Audio Voice Recorder Live Real-Time Audio Thru App | Charger & 32GB SD Card picture

WIFI Audio Voice Recorder Live Real-Time Audio Thru App | Charger & 32GB SD Card

$129.00



NEW Mitsubishi A1SNMCA-8KE Memory Cassette picture

NEW Mitsubishi A1SNMCA-8KE Memory Cassette

$151.62



Argolladora We R Memory Keepers Heidi Swapp Cinch Binding Machine 71050-9 by AC picture

Argolladora We R Memory Keepers Heidi Swapp Cinch Binding Machine 71050-9 by AC

$79.99



WiFi Audio Voice Recorder Audio Alerts Check Audio Real-Time 32GB USA Shipper picture

WiFi Audio Voice Recorder Audio Alerts Check Audio Real-Time 32GB USA Shipper

$129.00



1PC New ABB ACS880-MU-ZCU-12/14 ZMU-02 Inverter Memory Card 1year waranty picture

1PC New ABB ACS880-MU-ZCU-12/14 ZMU-02 Inverter Memory Card 1year waranty

$79.39







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.