BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-15-2007, 08:25 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Custom Buttons Problem

Please Login to Remove!

I have gone through the CustumButton app .but i am not able to figure out how to interact with custombuttons.As in they dont react when i click on them even after i do "setChangeLstener".i think this does not work bcos the state of the buttons does not change.

I want to perform an action when i click on the custombutton.i am working on it but havent yet figured out how.

could someone pls help.
__________________
Thanks
Meenal
Offline  
Old 05-15-2007, 08:38 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

does this work?

ButtonField okButton = new ButtonField("OK", ButtonField.CONSUME_CLICK);

okButton.setChangeListener(new FieldChangeListener(){
public void fieldChanged(Field field, int context){
Status.show("You clicked the button");
}
});
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 05-15-2007, 08:59 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

no it does not work.when i click on the button it shows me the default menu.
here the code i have:
Code:
Rectangle =  new CustomButtonField("rectangle",CustomButtonField.RECTANGLE,Field.FOCUSABLE) ;
mainScreen.add(Rectangle);
 Rectangle.setChangeListener(new FieldChangeListener(){
public void fieldChanged(Field field, int context){
Status.show("You clicked the button");
}
});
__________________
Thanks
Meenal
Offline  
Old 05-15-2007, 10:46 AM   #4 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Replace your CustomButtonField with the above code - does that work? If it does the problem lies with when you create your custom buttom - are you following the CustomButtonField example correctly? - this isn't part of the api - it's just an example of an object that extends Field if i remember correctly, the full source is available in the Application Developer Guide pdf
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 05-16-2007, 01:19 AM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

what i want to do is that use certen icon for gui...thats y i was refering to custombuttons application....but i cannot figure out perform an action when i click on them....focus come alright.I dont know where i am missing out on.Infact i have modifyed the same program.but i am not able to make it listen to trackwheel click.

will i have to use it a TrachWheelListener()?

Or could u suggest where i am missing?
Its the same example...i have just replaced the shapes with bitmaps.

Thank You
__________________
Thanks
Meenal
Offline  
Old 05-16-2007, 03:52 AM   #6 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You don't need to create a new custom object to do that, you can use overrides on the BitmapField object, the code below includes a rollover icon:

BitmapField myField = new BitmapField(icon1, BitmapField.FOCUSABLE | BitmapField.FIELD_HCENTER | BitmapField.FIELD_VCENTER){
public void onFocus(int direction){
setBitmap(icon2);
//optionally do something on rollover
}
public void onUnfocus(){
super.onUnfocus();
setBitmap(icon1);
}
public boolean trackwheelClick(int status, int time){
Status.show("button clicked");
return true;
}
};
add(myField);
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 05-16-2007, 05:31 AM   #7 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank u....it worked.

Just one more question.
Can we change the BackGround color of a ButtonField.i tried using setBackgroundColor(Color.Red) ... but yet it remained either blue(onfocus) and otherwise gray.

using the setBackgroundColor(Color.Red) method i managed to change background color of LabelField....but havent been able to do for ButtonField.
Code:
ButtonField btn1 = new ButtonField("Button 1") {
    protected void paint(Graphics g) {
         g.drawBitmap(0,0, mybitmap1.getHeight() , ybitmap.getWidth), mybitmap1 ,  0, 0);
         g.setBackgroundColor(Color.RED);
    }
     protected void layout(int width,int height) {
          setExtent(mybitmap1.getHeight(),mybitmap1.getWidth());
     }
};
__________________
Thanks
Meenal
Offline  
Old 05-16-2007, 07:18 AM   #8 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

pretty sure you can't change the colours of the buttons as these are defined by the theme on the device.
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 05-17-2007, 01:02 AM   #9 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

hmm....thought so.
__________________
Thanks
Meenal
Offline  
Closed Thread


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





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