Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
greenback
Posts: 532
Registered: ‎10-17-2010
My Device: BlackBerry Z10, DAC
Accepted Solution

Customizing ToggleButton Text ON/OFF

Hello. I need to change the ToggleButton text (On/Off) to something else. How do I do this?

 

Please help!

Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: Customizing ToggleButton Text ON/OFF

At first glance I don't see any way of doing this. I'll check further and report back though.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: Customizing ToggleButton Text ON/OFF

Confirmed: this is not currently possible. I've submitted a change request though to see if we can open up this property.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Customizing ToggleButton Text ON/OFF

Of course if you don't want to wait :smileyhappy: it would be easy enough to make your own one, with or without the animation.

 

What's the reason for wanting to change it BTW as you will lose the translation for users in different locales, unless you explicitly check for it?

 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: Customizing ToggleButton Text ON/OFF

Interestingly I wondered if you could "abuse" the localization system to make the text change but couldn't get that to work.

 

You wouldn't lose the translation with your own custom control. You'd add translations to your .ts file referencing the text values in your qml file. So I think that aspect would be OK.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Customizing ToggleButton Text ON/OFF

[ Edited ]

@mwoolley How many developers cover as many languages in their apps as BlackBerry do? :smileywink:

 

In the end it would be a weigh up between how important it is that the words are different versus how important it is that multiple locales understand its meaning.

 

Personally if there is a label associated with the toggle I would change the question.

 

i.e.

   Choose your temperature:  C/F

to

   Use Centigrade: On/OFF

 

Or use a DropDown instead.

 

@greenback, What are the words you want to change to? 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: Customizing ToggleButton Text ON/OFF

It was a valid point.

 

You wouldn't need to include every conceivable language in your translation file, just those you want to.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Developer
greenback
Posts: 532
Registered: ‎10-17-2010
My Device: BlackBerry Z10, DAC

Re: Customizing ToggleButton Text ON/OFF

I am creating "switches".

 

The three combinations I need to change the ToggleButton to are:

 

  • Available/Busy
  • Open/Closed
  • Yes/No
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Customizing ToggleButton Text ON/OFF

It really wouldn't be difficult to do the custom control yourself, you can even avoid creating the graphics yourself by taking the ones BlackBerry have already done.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
New Contributor
jboylan
Posts: 7
Registered: ‎11-04-2013
My Device: Blackberry Q10

Re: Customizing ToggleButton Text ON/OFF

This is where the Image Toggle Button comes into play.

 

    ImageToggleButton {
        horizontalAlignment: HorizontalAlignment.Center
        id: toggleLeftRight
        imageSourceChecked: "asset:///images/togRight.png"
        imageSourceDefault: "asset:///images/togLeft.png"
        imageSourcePressedChecked: "asset:///images/togRight_touch.png"
        imageSourcePressedUnchecked: "asset:///images/togLeft_touch.png"
    }

 

So something like this: