I'm making ToggleButtons programmatically and I want to set the on_state method, but it doesn't seem to work:
tbutton = uix.togglebutton.ToggleButton(multiline=True,markup=True,text=text,group="g",size_hint=(1,None))
tbutton.bind(on_state=self.my_function)
def my_function(self,*args):
print "TEST"
If I press the button nothing seems to work.
You should bind state - not on_state ...
tbutton.bind(state=self.my_function)
That it :)
Related
I have a custom framework for UITextField. For now, I want to disable two attribute as the question above but still keep the cursor show in my custom textfield. I already disable the keyboard with set the inputView = UIView(), and that successful for hide the keyboard even show the cursor inside textField.
My goal is disable both attributes like above or another for can not Select All action from my textField, but still keep the cursor available anytime.
Hope to hear the ideas from you guys. Thank a lot!
I inserted a UITextView into a view controller. I want to set the text to, for example, this:
hello
world
I can just add an outlet to the view controller class and set it like this in viewDidLoad:
myTextView.text = "hello\nworld"
But I want to be able to set it directly in interface builder! So I tried the following and they all didn't work!
typing "hello" and press return
typing "hello\nworld"
typing "hello" and shift + enter
I finally tried to write the text somewhere else and copy/paste it into the box and it finally works!
But seriously? Is there a better way to do this?
In the interface builder use (option + enter) instead of (shift + enter).
In the interface builder use (alt + enter) or (option + enter).
Hope this will help you.
My question is, how do I remove the "border-radius" of the textfield in Swift? Is it achievable in xCode or do you need to do a customized textfield? If so, how do I do that? I want the default textfield but without it's "border-radius" if you know what I mean.
Help, please!
UITextField has an attribute borderStyle, which can be changed either in interface builder:
...or in code:
public var borderStyle: UITextBorderStyle // default is UITextBorderStyleNone. If set to UITextBorderStyleRoundedRect, custom background images are ignored.
You can set the border style using Storyboards.
And also you can set border style programitically
[txtUserName setBorderStyle:UITextBorderStyleNone];
What do you exactly mean with border-radius? the border around it?
You can turn that off by clicking the button in xcode:
Or if you want to do it programmatically do:
myButton.bordered = false
The help indicates that adding gboGroupStyle to the ButtonOptions on a TButtonGroup:
"Specifies that the buttons should inherit the group style that is set on the container."
But this explanation still leaves me lost - any ideas?
The gboGroupStyle option in the TButtonGroup.ButtonOptions property has nothing to do with GroupIndex as it's known e.g. from TSpeedButton.
Setting of the gboGroupStyle option to True allows you to:
set the TButtonGroup.ItemIndex property, so you can predefine which button will be focused as default, nothing cool
click the buttons with ENTER or SPACE keys, what will fire the TGrpButtonItem.OnClick event of the button item (if assigned), perform its action, or fire the TButtonGroup.OnButtonClicked event
I agree the name of this is quite misleading, but that's what I found in the source code from Delphi-XE2.
gboGroupStyle makes the TButtonGroup act as a group - that means, one and only one button is selected at a given time. It is similar to grouping several TSpeedButtons with the GroupIndex, where only one button inside that group is selected at any time. The currently selected button can be read and written via the ItemIndex property of TButtonGroup. To visualize the selected button one can implement an OnBeforeDrawButton or OnDrawButton handler.
From my experimentation it looks like if gboGroupStyle is used then the ItemIndex property can be set to something other than -1, so that the TButtonGroup remembers the last button that was pressed.
I want to add a variable place holder in my textField and when something is written in textField, that text should be appended to place holder without any change to place holder. How should I go about it?
you can do this by using clearsOnBeginEditing property and set it to FALSE.
textField.clearsOnBeginEditing = NO;
If you are creating textfield by interface builder then you have to go to inspector in Interface Builder(Press command 1) and finally you have to uncheck the Clear when editing begins option.