Is there a way to keep the floating label highlighted while text is being input in the same box - autocomplete

I am currently working on a phone number field using Material UI Components.
The field structure is as follows
<Box>
<Autocomplete />
<TextField />
</Box>
The Autocomplete field (used for country code) has a floating label which reads 'Mobile Number'.
When the country code is selected, it is highlighted, however, when the mobile number is to be entered in TextField, it is not highlighted anymore.
Is there a way that the floating label can stay highlighted as long as any component within the box is selected?

The TextField in Autocomplete takes input props, one of which is InputLabelProps. This controls the highlight and shrink of the label.
InputLabelProps has 2 attributes which control the focus and shrink of the label
InputLabelProps: {
focused: true/false,
shrink: true/false,
}
The value of both attributes is boolean and decides whether the label should be focus or shrink.
The values of these attributes can be controlled using hooks.
const [focus, setFocus] = useState(false);
This is an example of how it works for Autocomplete. You can set the value of focus based on certain events.

Related

How to hide/show and image or textField on last page?

In Jasper studio how can I disable/show background for a single page in the report.
I want to disable the watermark image which I set in the background for the last page.
The simplest method that I know when you need to compare current page towards totale number of pages is to use evaluation type "auto" on the element.
From EvaluationTimeEnum
Variables will be evaluated at a time corresponding to their reset type.
Solution adapted from lucianc's answer at https://community.jaspersoft.com/questions/514622/print-when-last-page
Create a variabile that contains current page having reset type Page (so it's evaluate when Auto as current page number)
<variable name="currentPageInAutoEval" class="java.lang.Integer" resetType="Page">
<variableExpression>$V{PAGE_NUMBER}</variableExpression>
</variable
set evaluation time to "Auto" on your element (textField, image etc) and in expression use ternary operator
In your case, no image on last page it would be
<image evaluationTime="Auto">
<imageExpression>$V{currentPageInAutoEval}.equals($V{PAGE_NUMBER}) ? null : yourImage</imageExpression>
</image>
Hence with evalutationTime="Auto" $V{currentPageInAutoEval} will be evaluated as resetType (Page) to current page number and $V{PAGE_NUMBER} as the total number of pages.

How to bind footnotes in JasperReports

I have Textfields with dynamic position. It has footnotes, e.g. "some text1". And this footnotes are in the footer.
Footenote must be on the same page with textfield. Textfield has a float position and its location depends from dynamic size of Textfields above. With different conditions the field is located on different pages
How to bind TextField whith footnote in one page, e.g. Textfield is on the page number 3 and footnote on the same page? I can use $V{PAGE_NUMBER}, but how to get current page of TextField?
I have added $P{REPORT_PARAMETERS_MAP}.put("id_1",$V{PAGE_NUMBER})) at the end of textFiled Expression and $V{PAGE_NUMBER}.equals($P{REPORT_PARAMETERS_MAP}.get("id_1")) in the PrintWhenExpression of textField in the footer

Will focus be set to invisible form controls using HTML5 autofocus?

As the title states: Will focus still be set on form controls with autofocus="autofocus" even if they are hidden with display: none; or visibility: hidden;?
If your question is whether a hidden field can steal autofocus from a visible one, the answer is no.
Hidden fields with an autofocus property get focus when they are made visible.
Here's a jsFiddle that shows what happens if you have a visible field and a hidden field, then show the hidden field.
And here's a variation that demonstrates what happens if the visible field does not have an autofocus property.
The HTML5 draft standard only requires that an element be "focusable" where focusable means:
An element is focusable if the user agent's default behavior allows it
to be focusable or if the element is specially focusable, but only if
the element is either being rendered or is a descendant of a canvas
element that represents embedded content.
User agents should make the following elements focusable, unless platform conventions dictate otherwise:
a elements that have an href attribute
link elements that have an href attribute
button elements that are not disabled
input elements whose type attribute are not in the Hidden state and that are not disabled
select elements that are not disabled
textarea elements that are not disabled
command elements that do not have a disabled attribute
Elements with a draggable attribute set, if that would enable the user agent to allow the user to begin a drag operations for those
elements without the use of a pointing device
Editing hosts
Browsing context containers
It does say "but only if the element is either being rendered..." and the standard defines "rendered" as:
An element is being rendered if it is in a Document, either its parent
node is itself being rendered or it is the Document node, and it is
not explicitly excluded from the rendering using either:
the CSS 'display' property's 'none' value, or
the 'visibility' property's 'collapse' value unless it is being treated as equivalent to the 'hidden' value, or
some equivalent in other styling languages.
Just being off-screen does not mean the element is not being rendered. The presence of the hidden attribute normally means the
element is not being rendered, though this might be overridden by the
style sheets.
User agents that do not honor author-level CSS style sheets are nonetheless expected to act as if they applied the CSS rules given in
these sections in a manner consistent with this specification and the
relevant CSS and Unicode specifications.
In short, the answer appears to be that if all other requirements are met then display:none won't be focused but display:hidden will - Assuming all browsers actually follow the spec.

Checkboxes in Xcode

What I'm wanting to do is add checkboxes and have a title for each checkbox and have if certain boxes are checked then it displays certain texts like
if box 1, box 2, box 4, and box 5 are selected then displays text1
if box 1 is selected then displays text2
if box 1, box 3, and box 4 are selected then displays text3
Something like that. Help would be appreciated. Thanks.
For the UI use a UiTableViewController with two images one for unchecked and the other for the checked state. Those images are assigned to the UITableViewCell's imageView property.
For checking state, I would store all values into one int field and make a corresponding typedef enum so that i could use a bitwise & to check to see if a value or combination of values is selected.
I could post some code later if needed.
You can use UISwitch controls for a simple on/off control, and UILabel controls for text. You could have a single UILabel whose text changes, or multiple ones and mark them hidden depending on which switches are on.

Formatting field data color based on condition

I'm new to JasperReports. I'm designing report using iReport. My requirement is I have two values (Fields) x,y to compare. If x < y then the data color for y should be changed to 'black' & if greater then data color of y should be changed to 'red'.
Please advice me as to how to proceed on this & where to validate.
I know this is an old question, but in I am assuming Jasper Reports has changed. You can now accomplish this with Conditional Styles.
In iReport you create a new Style and give it a name. You can put any default settings, such as font, color, text size, etc. in the style. Then you right click the Stlye and select Add Conditional Style. Then on the field or fields you want to apply it to you set the style to one you created.
So in your example I would set the Forecolor in the main stlye to be black, set the Condition Expression in the Conditional Style to be
$F{y} > $F{x}
and the Forecolor in the conditional Stlye to red. Then in the detail section where you have the y field placed set the style to the one we created.
There's a discussion at the JasperForge forums on the topic, this is probably the most relevant part:
First drag and drop the field that you want to have dyanamic color twice. Change background color for first field to Yellow and the second field to Red. Now right click Yellow field, click Properties, select Common tab and write this code in the 'Print when expression' box: (make sure to replace myconditionalfield with your actual field name) $F{MyConditinalField}.intValue()>= 5 && $F{MyConditinalField}.intValue()<10?Boolean.TRUE:Boolean.FALSE //if >=5 and <10 then show Yellow field //Code for Red field at the same place just like above $F{MyConditinalField}.intValue()>= 10?Boolean.TRUE:Boolean.FALSE Hope this helps.
It's not exactly what you need, but might likely be close enough to push you in the right direction.
Example to color the even row and odd row is below , hope that help
<style name="BackgroundStyle" mode="Opaque" backcolor="#FFFFFF">
<conditionalStyle>
<conditionExpression><![CDATA[Boolean.valueOf($V{REPORT_COUNT}.intValue() % 2 == 0)]]></conditionExpression>
<style backcolor="#CCFFCC"/>
</conditionalStyle>
</style>
And assign style to each column , worked with me :)