Don't know how to set the default value for a UITextField without editing the placeholder - interface-builder

How do I create a default value for a text field (I want it to be 0) without editing the place holder? I will be using the interface builder if this helps.

Related

How to set the default writing direction for NSTextView?

I'm trying to set up a text view that a user can type Hebrew text into from right-to-left. Currently it defaults to a left-to-right text direction, which the user can manually change by right-clicking and selecting "Writing Direction > Right to Left", but what I need is for the text view to always default to this, without requiring the user to set it manually.
There's an option for setting this in Interface Builder, which is always ignored when I build and run my app.
I would be fine setting it from code, but I can't figure out how to use the method that looks like the closest thing to what I need:
hebrewTextView.setBaseWritingDirection(NSWritingDirection.RightToLeft, range: <#NSRange#>)
The range is stumping me. If it takes a range can this be the method I need? Wouldn't the default behavior of a field be independent of any range of text?
Is there a way to set the default writing direction for a NSTextView? Can this be done from the storyboard/interface builder, or from code? If setBaseWritingDirection is the method for this, what is the range value for and how would I set it for a field that is initially empty?
NSTextView inherits from NSText. NSText has a baseWritingDirection property. Try setting that:
hebrewTextView.baseWritingDirection = NSWritingDirection.RightToLeft
It also inherits the action method makeBaseWritingDirectionRightToLeft() from NSResponder, which presumably what the contextual menu uses. So, you could call that.
If neither of those works, you can set the text view's defaultParagraphStyle to one whose baseWritingDirection is right-to-left:
var style = hebrewTextView.defaultParagraphStyle.mutableCopy() as! NSMutableParagraphStyle
style.baseWritingDirection = NSWritingDirection.RightToLeft
hebrewTextView.defaultParagraphStyle = style

Removing text from NSTextView

I have created an NSTextView and managed to populate it using a getter for the scroll view that it is nested in, and using the .insertText() function.
How do I empty the same NSTextView? I have read the documentation and there doesn't seem to be a function .removeText(). It seems a bit weird that Apple would allow you to insert data but not remove it programmatically. I have searched high and low for answers but have come up empty handed.
You can't set the text of the text view directly, but you can set its textStorage's, getting that object's mutableString, which it inherits from NSMutableAttributedString, and then using setString(), passing an empty string.
No idea what I was thinking. Use var string { get set }, inherited from NSText.
If you set the text on the textview directly you'll lose the ability to automatically have the undo manager pick that change up.
I've found it more reliable to first select all the text and then delete it.
[self.textInput selectAll:self];
[self.textInput delete:self];

jqgrid disable input and change text color in IE

Is there a way in IE to disable cell input inside grid and change it's color (so it won't be gray)?
Or Is there another way to disable an input - and not by changing it to "readonly"?
UPDATE:
I'm using inline editing , and my cell input is a regular simple input (editable:true, edittype:'text'). I want this input to be disabled but to changed it's text color to black when it is disabled.
Thank's In Advance.
The answer how to change the editable attribute temporary for some column before stating of editRow. In the way no input element will be created and you will not have toe problem which you try to solve.

Change cell content in NSTableView before editing

I have an NSTableView that allows inline editing on one of its cells (NSTextFieldCell). This actually works well, but I want to manipulate the content for the editing session.
Imagine having a string with a path (say: "folder/subfolder/myfile.txt") as the content of such a cell. But when the user enters edit mode for this cell (e.g. by double clicking) I want only the string "myfile.txt" to be editable (i.e. to appear in the editor). How can I achieve this?
You could create a custom NSFormatter that does this. Override the method stringForObjectValue: to return the full string and editingStringForObjectValue: to return only the part you want to edit. You also need to write a method getObjectValue:forString:errorDescription: to transform the edited string back to the complete string. How to exactly do this depends on the rest of your program. You somehow need to get back the part of the string you removed for editing.

NSStepper ignores current NSTextField value

I have the same initial problem as described in Integrate NSStepper with NSTextField:
I need to have a NSTextField working with a NSStepper as being one control so that I can edit an integer value either by changing it directly on the text field or using the stepper up/down arrows.
Using bindings as commented on by carlosb results in a usable UI. However, in the initial question carlosb describes the following:
Problem is that if I edit the text field then click the stepper again it will forget about the value I manually edited and use the stepper's internal value.
This is why I am posting a variation on this question again. carlosb's use of bindings doesn't solve this problem. This happens in both the current project I am working on and a test project I have created. The test project can be found at GitHub. You can download it there (even without git) via the "Download Source" button in the top right.
Is there a clean way to solve this issue?
Text fields and sliders are both in the view layer of the MVC pattern. You'll have much better results by binding both of those views to a property of your controller.
Your problem is that that the editing isn't ended until you press return or the field loses focus (so the number is never actually changed). If you press return or leave the field after editing, you'll see it works as expected.
One solution is to check the "Continuously Updates Value" option in the text field's value binding and check the "Continuous" option in the text field's attributes.
This will make sure the value is being updated as it's typed, so an immediate click on the stepper will reflect these changes.

Resources