In HaxeFlixel, What is Box object and how to use it? - checkbox

I'm trying to use FlxUICheckBox. In the official documentation, the constructor looks like this:
new(X:Float = 0, Y:Float = 0, ?Box:Dynamic, ..)
What is the Box object?
How should I send a Box object as a parameter to this constructor?

I should probably change it to BoxAsset. It's the image asset you want to use for the box part of the checkbox.
A simple checkbox has three components, and looks a bit like this:
[X] Checkbox
Box means the box part, "[ ]"
Check means the check part, "X"
Label means the text that goes in the textfield next to the checkbox
If you don't provide Box or Check, it will use default FlxUIAssets automatically to skin your checkbox. If you provide your own asset (such as "assets/mybox.png" for example), it will use that instead. It is expecting the same sort of thing you would pass into FlxSprite.loadGraphic() -- a String, a BitmapData, or a FlxGraphic.
I should probably also update the type from :Dynamic to :FlxGraphicAsset, I originally wrote this code a long time ago before they added that new helper type.

Related

Extjs 6.0 - ItemSelector: how to programmatically focus/highlight an element?

I have a ItemSelector component inside a Window. I have implemented a search functionality that dynamically finds the matching entry based on user's keyboard input.
Now I just want to highlight/focus such item inside the ItemSelector.
I'm looking for something like:
// when the search returned a result and got the related index in the store
function onSearchPerformed(index) {
var cmp = this;
cmp.itemSelector.setSelected(index); // here I'd be highlighting the entry
}
Example
Imagine a simple ItemSelector like this one taken from the web.
User types 'Delaw' and my search function detects that there is an entry with name Delaware and it's at position 3 in the store.
All I want to do is to programmatically highlight the row/entry 'Delaware' just as if you clicked on it.
This ux component uses a boundList, or better 2 of them.
A from and a toList.
You need to get a reference to the right boundlist.
More on that you will find here: http://docs.sencha.com/extjs/6.0.1/classic/src/ItemSelector.js.html
Basically you can do something like this:
https://fiddle.sencha.com/#view/editor&fiddle/24ec
afterrender: function(cmp){
Ext.defer(function(){
var boundlist = cmp.down('boundlist');
item = boundlist.all.item(1);
boundlist.highlightItem(item);
},300);
}
After you have a ref to the correct boundlist, you can simply highlight the item using:
http://docs.sencha.com/extjs/6.0.1/classic/Ext.view.BoundList.html#method-highlightItem
Take care that you may need to call following function before:
http://docs.sencha.com/extjs/6.0.1/classic/Ext.view.BoundList.html#method-clearHighlight
To find the correct item should't be too hard.
There are two ways to solve the issue
One is by following #devbnz answer, marked as correct. This is preferable, if you just want to graphically highlight the entry without triggering any event.
However, by hovering on other entries, you will lose the highlight on your current entry.
The second one, as suggested by #guilherme-lopes in the comments, may be preferable in cases in which you want the selection to act as if you actually clicked on an entry, which will trigger the selectionchange event and similar...
Depending on the situation, I ended up using either.

How to Print the Disabled text from Geb/Groovy?

enter image description here
We are automating the UI Application, Our UI application have Disabled Text are present, so we need to Validate the Disabled text. Before validating, I have to Print the Disabled text, Please guide me to how to print the text using Geb/Groovy.
Please find the Image of HTML tag which i highlighted is the Disabled text
BNSF0000712570
BNSF0000712570
The selector above will yield multiple results, i.e. elements, if there is more than one element that matches the classes used in the By.cssSelector query.
To get only the element containing "BNSF0000712570", I would suggest you try to get it using the "ext:qtip" attribute instead (which I assume is unique per element containing a disabled text) on the div containing the disabled text:
def myText = $(“div[ext:qtip=‘Id: 0001’]”).text();
println myText;
assert myText == "BNSF0000712570";
#Saurabh Gar: Why would you use the WebDriver "By" class selectors? With Geb you have access to a wide range of simpler ways to write selectors, e.g. like the one used above.
You should try using By.cssSelector as below :-
def text = driver.findElement(By.cssSelector("td.x-grid3-td-elementvalue").text
Or
def text = driver.findElement(By.cssSelector("div.x-grid3-col-elementvalue").text
assert text == "BNSF0000712570"
println text
Note:- If still doesn't get the text need to share table HTML insteadof screenshot that's why, could make a best locator.
Hope it helps..:)

Codename One - get selected text from AutoComplete

How can I get the complete selected text from an AutoComplete TextField?
If I use getText(), I only get the few letters the user has input so far.
Example: I write "flo" and then select "Flowers" from the list, but getText() gives me "flo"
AutoCompleteTextField auto = new AutoCompleteTextField(arrayWithNames);
auto.setMinimumLength(4);
auto.addListListener((ActionEvent evt1) -> {
String lookedFor = auto.getText();
Hashtable<String,Object> match[] = findMatch(lookedFor);
if(hMatch.length>0){
contElements.removeAll();
for (Hashtable<String, Object> Match1 : match) {
...
...//fill the Container with the names found
...
}
}
});
How it works
I am using the AutoComplete TF as a search button.
I have an array with all the names in my list.
Then I populate the Auto with the array.
The user selects a name from the Auto and then I search the value that is being "lookedFor" using the findMatch(). It returns a new array with the found entries.
I need the complete name from the list so I can use the findMatch() method, but when I use getText() from the Auto, it only returns the letters the user entered, and not the whole name, so my method does not work, since I am comparing whole Strings.
(I am using the Auto because it is very convenient if people remember only a part of the name they are looking for)
If you subclass AutoCompleteTextField you can access the selected text internally via getSuggestionModel().getItemAt(getSuggestionModel().getSelectedIndex()). Now you can define a public getter method getSelectedText() or something on your derived class.
I am not sure you are using the AutoCompleteTextBox correctly.
The entire purpose of the AutoCompleteText box is to help you assist the user in selecting from a list of valid requests,
You should not be getting the value of getText() until the user is ready to submit the form where the AutoCompleteTB is located.
This WILL help if you haven't already looked here:
https://www.codenameone.com/javadoc/com/codename1/ui/AutoCompleteTextField.html#getPropertyTypes--
Good luck!

Xpages Combobox -setting the default value

I have a combobox with values being populated from a managed bean like so:
keywordlist.setConnDB("jdbc:sqlserver://xx.xx.x.xx:1433;DatabaseName=xxx");
keywordlist.setConnUserName("xxx");
keywordlist.setConnPassword("xxx");
keywordlist.setSQLQuery("SELECT DisplayText as Keyword From Glossary WHERE SUBSTRING(DisplayText, 1, 2)= 'RV'");
keywordlist.keywords;
I'd like to be able to set the default to '--- Select ---', but no matter what I do the keyword list always picks the first of the returned keywords as the default.
Any assistance would be much appreciated.
Thanks,
Dan
Add another value pair (on first position), type "formula item" with the following SSJS return value:
"-- Select --|"
Notice the pipe!
That should display this at first position and should also be defaulted as "empty" is the default value. If not, set the "alias" (the value after the pipe) to something that you can define as default value porperty for the combo item.
It might be because you're binding to the bean directly. You might have to add that value to your keyword list itself. I think I have an example of this in a NotesIn9 show: http://notesin9.com/index.php/2014/03/13/notesin9-138-xpages-combobox-improvements/
I'm not sure. If I don't have a default in the java code you can probably see how it might be done.
Try that. If that doesn't work at all then maybe you don't bind the combo box to the bean directly. Maybe bind it to a viewScope var... since that can be anything it'll take a blank... then you just need to move the viewScope var value back up to your bean in the onChange event or something.
Just a quick thought...
Basically, the following pattern could be a start point for such a combobox:
<xp:comboBox
id="comboBox1"
defaultValue=""
value="#{document1.someField}">
<xp:selectItem
itemLabel="--- Select ---"
itemValue=""></xp:selectItem>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:
// Your SSJS code...
// Should return some kind of list...
return items;
}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
Alternatively, you can grab the keyword values from a Java bean:
<xp:selectItems value=#{yourBean.yourValue}></xp:selectItems>
Still, it's important to return a list value. It might also have "label|value" format.

Getting the display text of an object

I would like to know whether there is any mechanism to retrieve the display text of an object. As far as I know, there's no direct LSL function for that.
Isn't there any property that we can use to extract this information?
Assuming you mean the text that hovers over an object:
That text is set by calling llSetText, but there is no corresponding llGetText. Instead, you can use llGetPrimitiveParams with the constant PRIM_TEXT, like so:
list params = llGetPrimitiveParams([PRIM_TEXT]);
string text = llList2String(params, 0);

Resources