0

I am attempting to add a central button to my CodenameOne project via code, I already add two commands that provide specific behaviour.

I have managed to see the third soft button when doing:

Display.getInstance().setThirdSoftButton(true);

Which gives a contextual command based on the component from what I can see. What I am aiming to have is the contextual behavior when possible but allow the current form to override the button and provide its own functionality.

So there are two questions:

How do I maintain the behavior of my two current commands and prevent them from moving left or right or losing order. And also how do I override the contextual button to provide my own command regardless of the current focused component?

JamieB
  • 923
  • 9
  • 30

1 Answers1

1

This is a really old feature that dates back to LWUIT and the original Nokia 3 button phones so it might have regressions.

Generally to customize the command text you can just invoke setSelectCommandText on the specific component. When the select command is invoked on a component the method fireClicked is invoked on that component, if you want to change the behavior you can override that method.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • Thanks for the response Shai, if I wanted to add a general command that didn't correspond to a component is that possible? An example would be if I am on a page with no components except a text area and I wanted to have the middle soft key as a progress to next page button. – JamieB Nov 13 '14 at 14:15
  • No. The middle softbutton is always an action on a component, notice that since the text area is focusable you can override that and it will work as expected. – Shai Almog Nov 14 '14 at 04:34
  • Appreciate the input Shai, I'll look into alternative solutions. – JamieB Nov 14 '14 at 11:15