BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 08-29-2006, 10:16 AM   #1
obijohn
Thumbs Must Hurt
 
Join Date: Oct 2004
Model: 7100t
Carrier: T-Mobile
Posts: 71
Default what's wrong with this button?

Please Login to Remove!

Why does a single-item "close" menu appear when this button is clicked with the trackwheel but no menu appears when it is "clicked" by pressing ENTER when it has focus? If I add an edit field, the default main menu appears when the trackwheel is clicked in the edit field (which is what I want), but when the button defined below is clicked with the trackwheel that single-item "close" menu appears (which I DON'T want). What am I doing wrong with this button?

Code:
// ----- ButtonTestScreen.java ----------------------------------
package buttontest;

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;

public class ButtonTestScreen extends MainScreen {
        
    public ButtonTestScreen() { }

    public boolean onClose()
    {
        Dialog.alert("BYE!");
        System.exit(0);
        return true;
    }
    
}
Code:
// ----- ButtonTest.java ----------------------------------
package buttontest;

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.system.*;

public class ButtonTest extends UiApplication implements FieldChangeListener
{
    private boolean clicked;
    private LabelField appTitle;
    private ButtonField testButton;
    private ButtonTestScreen mainScreen;
    
    public static void main(String[] args)
    {
        ButtonTest app = new ButtonTest();
        app.enterEventDispatcher();
    }
    
    public ButtonTest()
    {
        clicked = false;
        ButtonTestScreen mainScreen = new ButtonTestScreen();
        appTitle = new LabelField("Button Test");     
        testButton = new ButtonField("Click Me");   
        testButton.setChangeListener(this);           
        mainScreen.setTitle(appTitle);
        mainScreen.add(testButton);
        pushScreen(mainScreen);
    }

    public void fieldChanged(Field field, int context)
    {
        if (field == testButton)
        {
            if(clicked)
            {
                clicked = false;
                testButton.setLabel("Click Me"); 
            }
            else
            {
                clicked = true;
                testButton.setLabel("Clicked");
            }
        }
    }    
    
}
Offline  
Old 08-29-2006, 10:43 AM   #2
jfisher
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Default

Try:

testButton = new ButtonField("Click Me", ButtonField.CONSUME_CLICK);
Offline  
Old 08-29-2006, 10:50 AM   #3
obijohn
Thumbs Must Hurt
 
Join Date: Oct 2004
Model: 7100t
Carrier: T-Mobile
Posts: 71
Default

Quote:
Originally Posted by jfisher
Try:

testButton = new ButtonField("Click Me", ButtonField.CONSUME_CLICK);
YES!! That was it, thanks!
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


US Stock 110VAC 60W 40KHz Ultrasonic Cleaning Transducer Cleaner & Driver Board picture

US Stock 110VAC 60W 40KHz Ultrasonic Cleaning Transducer Cleaner & Driver Board

$50.53



Psi-Tronix Motion Transducer Mod. 20 picture

Psi-Tronix Motion Transducer Mod. 20

$150.00



RDP Electronics Transducer Indicator E309 picture

RDP Electronics Transducer Indicator E309

$245.00



CR Magnetic CR4180-20 True RMS AC Current Transducer 3 Element - New picture

CR Magnetic CR4180-20 True RMS AC Current Transducer 3 Element - New

$229.95



MTS LPRHVU00701 Temposonics Transducer Linear Position LPR-HVU-00701 90014868 picture

MTS LPRHVU00701 Temposonics Transducer Linear Position LPR-HVU-00701 90014868

$238.95



Transducer Techniques TMO-2-1600 Load Cell Signal Conditioner + SB0-50 load cell picture

Transducer Techniques TMO-2-1600 Load Cell Signal Conditioner + SB0-50 load cell

$158.00







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