Change text on datepickertoolbar buttons - localization

I need to localize the text on the datepickerfield buttons 'cancel' and 'done'.
I've tried localizing in general, but can't find options for these buttons.
And setting a custom set of buttons, but that only adds buttons, leaving the existing buttons there.
Anyone know how to do this?
Edit #DavidArtmann:
This is my datepickerfield, sadly your suggestion is not helping. Thanks for the option though, din't find it myself and according to the documentation it should.
{
xtype: 'datepickerfield',
name: 'policyStart',
label: 'Polis geldig vanaf:',
placeHolder: '',
labelAlign: 'top',
doneButton: 'Kies',
cancelButton: 'Annuleer'
}

I think the docs here: doneButton and here: cancelButton describes this very well.
You can simply give this config attribute a String, a Button Object, or false/null to hide it.
And if you want the value of an existing Datepicker Button Object, you can use the method getCancelButton() or getDoneButton(), which will return a String or the Button Object or null.
EDIT:
I'm sorry, I didn't read properly. You're using a datepickerfield. Which will pop up an datepicker, when tapped.
It will use its default config or your given one with picker or setPicker().
Here you can give him a button object with the text of your choice ;)
So an example config would be:
{
xtype: 'datepickerfield',
name: 'policyStart',
label: 'Polis geldig vanaf:',
placeHolder: '',
labelAlign: 'top',
picker: {
xtype: 'datepicker',
cancelButton: 'your_cancel_string',
doneButton: 'your_done_string'
}
}
note: this is not tested

Related

SwiftUI ActionSheet disabled button

This seems like maybe a simple question, but I'm looking for a way to make one (or more, I suppose) buttons in an ActionSheet in SwiftUI to be disabled. For example, if something is illegal based on the state of the app, I don't want to let the user click the button - indeed, I might change the text to explain why it's disabled.
Xcode autocomplete isn't really turning anything up for me, and the docs (here and here) aren't giving me anything. Is my best/only option simply not putting the button in the list of buttons in the ActionSheet? (And kinda letting the user infer why it's not there...)
Thanks so much for any advice!
My simple code:
private func getActionSheet() -> ActionSheet {
let buttons: [ActionSheet.Button] = [
.default(Text("This is fine...")) { foo() },
.default(Text("This is forbidden - disable me!")) { foo() },
.cancel()
]
return ActionSheet(title: Text("Do it!"), buttons: buttons)
}
For nondestructive actions you can simply show a Menu. They support the .disabled(true) modifier.
var body: some View {
Menu("Do it!") {
Button("This button works fine", action: { })
Button("This one is disabled", action: { })
.disabled(true)
}
}

How to enable/disable navigation bar buttons [XCode] (swift)

I was wondering how I would be able to go about changing the status of buttons. I want to make it if one of two text fields has text in them then the button will become useable. I have currently turned off the button from the storyboard. The code I have to check if there is text inside of the text fields is as follows:
Disclaimer:
The code to check if the text field has any text in it works perfectly fine.
#IBAction func textFeildEditingChanged(_ textField: UITextField) {
if FirstName.hasText == true {
self.navigationItem.rightBarButtonItem?.isEnabled = true
print("First name isn't empty")
}
}
The current code that I have in there to set the button to enabled and disable doesn't work however the code to test if the text field has content does work. I just need to figure out how to disable and enable the button of a navigation item.
code that doesn't work is below:
self.navigationItem.rightBarButtonItem?.isEnabled = true
Any help would be greatly appreciated.
Edit: I am using a navigation controller, don't know if that's important or not.
If you are using the storyboard, just connect the outlet then disable it.
#IBOutlet var navigationItemButton: UIBarButtonItem!
then
navigationItemButton.isEnabled = FirstName.hasText

SCLAlertView Button

When I used third party SCLAlertView there was a problem actually there is a problem that is I want to perform some action when the button will pressed but there is just the customization properties but I am wondering for the action scope can someone help me out?
you can use this
let appearance = SCLAlertView.SCLAppearance(
showCloseButton: false // if you dont want the close button use false
)
let alertView = SCLAlertView(appearance: appearance)
alertView.addButton("Ok Pressed") {
print("Ok button tapped")
}
alertView.showSuccess("Success", subTitle: "")
you get the detail example for add buttons and hide default close buttons property in SCLAlertView
I never used this library, however if we take a look at the Github repo of the project (https://github.com/vikmeup/SCLAlertView-Swift) we will see the following example:
alert.addButton("Show Name") {
print("Text value: \(txt.text)")
}
Where print("Text value: \(txt.text)") gets executed after clicking the button.

Any way to make text in all buttons/action of a UIAlertController bold?

I have a requirement that the text in the buttons of a UIAlertController should be set to bold for every button (as opposed to the standard iOS behavior which is that the button assigned the style cancel is bold, or that for which preferredAction has been set is bold. The requirement is that all button text should be bold).
Is there a way to achieve this using a UIAlertController? Or will I be forced to created a custom dialog using a UIView?
There's plenty of past questions/answers on manipulating the body text for a UIAlertController using an attributed string, but I've not found anything for doing the equivalent for the text of the action buttons of an UIAlertController.
Buttons on UIAlertController are of UIAlertAction. There are no any setter methods on any property of UIAlertAction available, so you can't change the button text to bold.
Even title have to be String type, it doesn't accept NSAttributedString. So you should go with a custom dialog using a UIView.
Apple class reference for UIAlertAction:
#available(iOS 8.0, *)
open class UIAlertAction : NSObject, NSCopying {
public convenience init(title: String?, style: UIAlertActionStyle, handler: ((UIAlertAction) -> Swift.Void)? = nil)
open var title: String? { get }
open var style: UIAlertActionStyle { get }
open var isEnabled: Bool
}
Or will I be forced to created a custom dialog using a UIView?
Yes, that’s it. But it’s very easy, and gives you much more power and flexibility than UIAlertController. There are lots of sample projects out there, and once you’ve used one you may never go back to UIAlertController again!

Disabled UITextView shows empty context menu on long press

I have a UITextView subclass where I specifically disable all context menu options:
class MyTextView: UITextView {
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
return false
}
}
I add an instance of MyTextView to a view that shows up in my app. I give the instance of MyTextView the following value: isEditable = false
When I long press on the UITextView however, I get the following:
This seems like a bug since there is nothing in this menu? Any ideas on how to prevent this?
Thanks!
Because selectable property is active. So you can "select" a part of text and iOS default behaviour is to show this popover.
You can disable this property by storyboard, or by code.
Storyboard:
At storyboard, select the textview and go to attribute inspector tab... Search for behavior and uncheck selectable checkbox.
or, if you prefer, you can solve it by code:
at viewDidLoad method, set the property isSelectable to false.
MyTextView.isSelectable = false
That's not "the menu". It's just the thing that magnifies the region where the press occurs:
It's empty in your screen shot only because you've no text, so we're magnifying nothing. The menu appears after your long press ends and the magnifier thing goes away — and it doesn't appear, so your code is working fine.
You can see easily that that's true by changing your code to return true. The empty magnifier will appear, just as it does now, and then when it disappears, the menu appears. Thus, we have proved that what you are seeing is not "the menu".

Resources