This is code of watermarktextbox.
<xctk:WatermarkTextBox Watermark="Enter First Name" />
How would I measure the height of that object?
It is simple as this :
Assign a name to your component and measure its height using Height property in code behind.
XAML :
<xctk:WatermarkTextBox x:Name="WatermarkTextBox1" Watermark="Enter First Name" />
Codebehind :
var height = WatermarkTextBox1.Height;
EDIT :
Please use this to get font height. Source : https://stackoverflow.com/a/9251215/5621607
private int GetTextHeight(TextBox tBox)
{
return TextRenderer.MeasureText(tBox.Text, tBox.Font, tBox.ClientSize,
TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl).Height;
}
Related
I have such an div element:
<div className="rate" >
<mark className="rate-mark"> Rate : </mark>
<mark className="val-mark" style={{color}}> {rate}</mark>
</div>
where the color is a hook:
var green = "#0cb87f";
var red = "#ce2020";
const [color,setColor] = useState(green)
I'm trying to dynamically change the color like this :
if (response.getRate() < rate){
setColor(red)
}else{
setColor(green)
}
But in my case it turns out that the light is always green.I think the mark page element is just never updated.How can this be made to work?
Is there any possiblity to display partial color to the string the devextreme data grid cell.
For example values which are greather than 5000 should be in red and rest should have default color.
Eg:
The devextreme datagrid has a cell with value "4995,4218,4445,4506,5145". I need to show only 5145 as red and rest values should not apply any color, because only 5145 is there 5000.
You can use a cell template to accomplish this.
<DataGrid>
<Column
dataField="myValues"
cellRender={renderGridCell}
/>
</DataGrid>
const renderGridCell = (cellData) => {
return (
// this is just an example. access the cellData parameter to get the values of your object
[4995,4218,4445,4506,5145]
.map(x => <span style={{ backgroundColor: x > 5000 ? 'red' : undefined }}>{x}</span>)
.reduce((acc, x) => acc === null ? x : <>{acc}, {x}</>, null)
);
}
Here is the cell data parameter description. You probably need to access cellData.value or cellData.data.
Is there a way in Qooxdoo to automatically adjust the width of the qx.ui.form.TextField to fit its Content?
It means if someone types in the Textfield it should grow and vice versa.
Here is an example in the Qooxdoo playground that listen to input's updates, use the canvas to calculate the text's length and adjust the textfield's width.
var tt = new qx.ui.form.TextField();
this.getRoot().add(tt);
tt.addListener("input",function(e){
this.setWidth(parseInt(getTextWidth(e.getData(), "12px Verdana"))+10);
},tt);
function getTextWidth(text, font) {
var canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
var context = canvas.getContext("2d");
context.font = font;
var metrics = context.measureText(text);
return metrics.width;
}
I have a qx.ui.table.Table that becomes hard to read when a row takes focus. I'm using qx.ui.table.cellrenderer.Date as a base class to override a cell's background color though it doesn't appear this method gets called when
focusCellOnPointerMove : true fires events.
So, where is the table getting styled at when a row takes focus?
Here is my override:
// Overridden
_getCellStyle : function(cellInfo)
{
var diff = 5; // Example
if (diff < 60)
{
var color = '#8cff5e';
return this.base(arguments, cellInfo) + "background-color:" + color + ";";
} else if (diff < 60 * 5)
{
var color = '#ffff00';
return this.base(arguments, cellInfo) + "background-color:" + color + ";";
} else
{
return cellInfo.style || "";
}
},
Using suggestion by scro34:
If you just want to change a table row's background color when it's pointed at you can use qooxdoo's theming capabilities and override the color declaration which comes with the theme you've applied to your application.
The table widget uses two color keys to control the background color when the pointer is hovering over a row: table-row-background-focused (unselected row) and table-row-background-focused-selected (selected row).
To override the predefined values, open Color.js which is located in the "theme" folder of your application and add two entries to the "colors" section of the file, e.g.:
qx.Theme.define("myApp.theme.Color",
{
extend : qx.theme.indigo.Color,
colors :
{
"table-row-background-focused" : "#8cff5e",
"table-row-background-focused-selected" : "#ffff00"
}
});
More information about theming in qooxdoo: http://www.qooxdoo.org/current/pages/desktop/ui_theming.html
Tutorial on table styling: http://www.qooxdoo.org/5.0.1/pages/desktop/ui_table_styling.html
I'm populating items to a comboBox from an xml file. I'm trying to customize the font-color of each item that appears in the comboBox. Any suggestions?
Thanks!
--Moe
The process is simple if you are using Flash Builder. Each item in your ComboBox is made of an ItemRenderer. Create a custom item render (file - > new -> mxml component) extending that basic ItemRenderer class then assign this new ItemRenderer to your ComboBox. Now inside your custom ItemRenderer you can change values, font sizes, etc ...
You will need to use an ItemRenderer. Though you have not mentioned but it seems you are using Flex 3. The way of using ItemRenderer is slightly different in Flex 3 vs Flex 4. So here is the version for Flex 3:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
<mx:XMLList id="statesXMLList" xmlns="">
<state abbrev="AK" name="Alaska" />
<state abbrev="AZ" name="Arizona" />
<state abbrev="AR" name="Arkansas" />
<state abbrev="CA" name="California" />
<state abbrev="CO" name="Colorado" />
<state abbrev="CT" name="Connecticut" />
</mx:XMLList>
<mx:ComboBox id="comboBox"
prompt="Please select a State..."
dataProvider="{statesXMLList}"
rowCount="3"
labelField="#name"
itemRenderer="ComboBoxItemRenderer"
/>
</mx:Application>
The class for ItemRenderer is ComboBoxItemRenderer which is shown below:
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
override public function set data(value:Object):void
{
super.data = value;
lbl.text = value.#name;
if(value.#abbrev == "AK") {
lbl.setStyle("color","#FF0000");
}
else if(value.#abbrev == "AR") {
lbl.setStyle("color","#FF00FF");
}
else {
lbl.setStyle("color","#000000");
}
}
]]>
</mx:Script>
<mx:Label id="lbl"/>
</mx:VBox>
Do not forget the last if (default case) whenever you override set data method.