Eureka form, TextAreaRow auto height - swift

Can I configure a TextAreaRow of an Eureka form to fill the available vertical space?
I will have just a few rows above and toolbar at the bottom.

You will have to play with textAreaHeight property values by setting up it initial height depending on device and available bottom space. Check out this pull request https://github.com/xmartlabs/Eureka/pull/416/files to see how it works.

You need to use textAreaHeight attribute to change the height dynamically
using .dynamic(with initial height value).
<<< TextAreaRow(){
$0.tag = tag
$0.placeholder = "PlaceHolder"
$0.textAreaHeight = .dynamic(initialTextViewHeight: 96)
}

Related

Change height of one of multiple fields in stack view

In my code I have a stack view that initially has 1 element PhoneNumberField. Another PhoneNumberFieldscan be added dynamically in the runtime:
#IBAction func addAlternatePhoneNumberAction(_ sender: UIButton) {
let alternateNumberView = PhoneNumberField()
...
phoneNumberStackView.addArrangedSubview(alternateNumberView)
}
This is what xib for PhoneNumberFieldlooks like:
The problem is that I would like to be able to dynamically hide the 'Name for other phone' field based on the content of 'Mobile combobox'. When I set the 'isHidden' parameter everything works as expected, the only problem is that the PhoneNumberField height stays the same. I would like it to shrink when the 'Name for other phone' field is hidden.
I tried doing it using the outlet for height constant for otherNumberNameField in the PhoneNumberField.swift file but the problem is that in that case all of the PhoneNumberFields in the stack view have the size of the first field.
What would be the correct solution for this?
edit: In addition to the answer below: I had to set the distribution for the phoneNumberStackView to equal spacing. Worked like a charm.
First, create StackView.
Don't set its height constraint, just set top, leading, trailing and bottom constraints.
Bottom constraint set equal to Error label top constraint.
Then set its distribution to Fill Equally.
Now put first two Views into one view and put this view together with OtherNumberField view to this StackView.
So now your hierarchy should look like this:
Now when you hide one view from StackView, StackView will be smaller because you didn't set its height.

NSTextField label: dynamically change content and grow width to fit

If I drag a Label (of class NSTextField) into a view in Interface Builder, and then attempt to set its stringValue dynamically like so:
self.testingLabel.stringValue = "Labels are really really really long"
Then most of the label will be cut off.
How can I make the label grow to fit its content without wrapping/scrolling?
I have tried using this custom class but it doesn't work.
class AutogrowTextField: NSTextField {
override var intrinsicContentSize: NSSize {
get {
var frame = self.frame;
frame.size.width = CGFloat.max;
// Calculate new height within the frame
// with practically infinite height.
let width = self.cell!.cellSizeForBounds(frame).width
Swift.print(width)
NSBeep()
Swift.print(self.frame.width)
return NSMakeSize(width, frame.size.height)
}
}
// you need to invalidate the layout on text change, else it wouldn't grow by changing the text
override func textDidChange(notification: NSNotification) {
super.textDidChange(notification)
self.invalidateIntrinsicContentSize()
}
}
Essentially I just want the default behaviour of an HTML document like this:
<p id="dynamic">Hi</p>
<script>
document.getElementByID("dynamic").innerHtml = "Something really really really long"
</script>
This is extremely painful for me as while I am new to Mac OS X and Cocoa, I am not a 'beginner' programmer.
In case it helps here is the contents of the attributes inspector. (it should just be all default values)
Yes, auto layout is enabled
Are you sure your NIB or storyboard is configured to use auto layout? That would be a checkbox on the File inspector.
The reason I ask is that the Attributes inspector would have a "Preferred Width _ First Runtime Layout Width" checkbox, immediately below the "Uses Single Line Mode" checkbox. It doesn't, which makes me think that auto layout is not enabled.
If you're not using auto layout, then you are responsible for either setting the label's frame size or, more simply, telling it to size itself to fit its content by calling sizeToFit().
If you're using auto layout, then the standard NSTextField already computes its intrinsicContentSize based on its string content. The problem is almost certainly with whatever other constraints you may have set on the view. You need to make sure that the auto layout system is free to adjust the label's width. So, you must not set an explicit width constraint. Or, if you have, say, both a leading and trailing spacing constraint, you need to make sure the label's compression-resistance priority is high enough to push the other related views out or compress them. Etc.

Set height and width dynamically for page/section in crystal report

I am using crystal report for printing details. I have two issues while printing.
Set height/width dynamically for section details
I want to change the height and width for the section dynamically through code. This height and width will come from user settings so I need those to be dynamic. When I checked, there is a option to set the section height programmatically but its not working. I am using the below code to set the section height
ReportDocument rd = new ReportDocument();
Section section = rd.ReportDefinition.Sections["Section3"];
section.Height = 1;
When I use this code, it gives me error "System.Runtime.InteropServices.COMException: The section height is not valid."
I also want to set "Gap Between Details" dynamically. Is it possible?
Set page content height dynamically
I want to set the page content height dynamically. We can set the page height and width from Design -> Page setup -> Page options -> Set Horizontal and Vertical values.
What is happening in my case is, I am using crystal report tp print barcodes. When the page height is big, it prints empty barcodes which I dont want. I want to set the page content height based on the number of barcodes I am going to print. How can I do this?
Can anybody help me solve these two issues?
I was finding how to resolve this question. For me, this works:
ReportDocument rd = new ReportDocument();
rd.ReportDefinition.Sections["Section5"].Height = 1000;
Try this, ok?
I added a formula field called AutoHeight and a parameter field called Height then I put this code inside the formula:
Local StringVar height = "";
Local NumberVar i;
For i:=1 to {?#Margin} do (
height := height + Chr(10)+Chr(13)
);
height
The final step is to place my AutoHeight formula in the section I want to control with the property Can grow checked

How to stretch a text field relative to data width in Jasper Reports

I have a text field followed by a static text field and I am trying to do 2 things with it:
Get the text field to stretch horizontally (not wrap) when text is longer then the field width and
Push the static text field right when the text field to the left of it stretches
Both of the fields are contained within a frame.
I have both fields set to positionType=float and the text field set to stretchWithOverflow=true, which enable text to wrap vertically but not stretch horizontally.
Is it possible to achieve 1 and 2 above? If so How?
Instead of having 2 text fields (dynamic and static), you can have 1 text field with value as $F{Field} + "statix text". This will probably fix your issue. Also, you can set the "width" and "stretch with overflow" properties, as per your requirements.
Well it's bad news!! According to Jaspersoft's documentation on stretching fields it is not possible to stretch the width of a field:
"Usually, the stretching process refers to the height adjustment only.
When stretching report elements, adjusting the width could affect also
the page width and raise unexpected errors at runtime (for instance,
truncated information could be printed out on pages). This is why
stretching an element let its width unchanged, while its height gets
definitely enlarged in order to make room for all information that
have to be displayed." (Jaspersoft documentation [v4.5.0], 2011)
However a solution to the original issue can be found here thanks to #mdahlman
Just select text field and from its textfield properties choose "stretch with overflow" and it will change its height dynamically according to text .enter image description here

spark form item gap in Flex

Is there a way to change the space between a spark form item and its content(textinput, conbobox)? I already set to 0 the "gap" property of the form, but still there is a lot of vertical space left between the form inputs.
Set the gap to -14 to get no gap between the items
<s:Form>
<s:layout>
<s:FormLayout gap="-14"/>
</s:layout>
<s:FormItem .....>
</s:Form>
The spark skin for formItem has left/right variables set based on "columns." I.e. left="column1:10" means the element is 10 pixels to the right of column 1.
So, create the skin, reduce those numbers in the "content" column area and check it.
Reducing all those numbers and the gap should tighten, along with setting the gap in form layout.
If you want to change the vertical gap between each Spark Form Item, create a custom skin based on FormSkin and change the gap property FormLayout.
If you want to change the horizontal gap between skin parts (labelDisplay, indicatorDisplay, helpContentGroup, ...), you need to create a custom skin based on FormItemSkin and change the ConstraintColumn values
I changed in my custom FormItem skin as followed, and it worked for me:
before:
<s:ConstraintRow id="row1" baseline="maxAscent:10" height="100%"/>
after:
<s:ConstraintRow id="row1" baseline="maxAscent:0" height="100%"/>
There are no paddingLeft, paddingRight etc. properties in FormItemLayout yet.