Print code of property binding in QML - binding

Is there a way to print the code of the property binding for a certain property in QML?
For example:
root.foo = Qt.binding(function() {return width + "2"})
console.log(<code of root.foo>)

There is no way to get body of a function in QML. Here you can read nice post about it:
https://stackoverflow.com/a/33878445/5163799
I think the same would be with a binding.

Related

How to show currency using swift-currency in SwiftUI inside of Text() without "Optional" being shown?

I am trying to use the following library: https://github.com/peek-travel/swift-currency
Issue I am having is if I have a varible:
let dollaramount:USD = USD(1.88)
When I do:
Text(dollaramount) // I get errors about "Initializer 'Init(_:)' requires that 'USD' conform to 'StringProtocol'
When I try:
Text("\(dollaramount)") // I get error about "Instance method 'appendINterpolation' requires that 'USD' conform to '_FormatSpecifiable'
What I try:
Text("\(dollaramount.localizedString()).") // No errors, but the SwiftUI Text element shows "Optional(USD(1.17))"
What is the proper way to show the string so that i don't get all the Optional(USD(1.17)) and just show "$1.17" like it should? Also, is it right to use USD as the type for this kind of variable? I've read that float and double should not be used for currency. If USD is not the preferred type when doing a lot of currency procesing, please provide the correct alternative.
since localizedString() return optional value. you can simply provide default value to avoid nil.
Text("\(dollaramount.localizedString() ?? "My optional").")

Assigning Value to StringValue In F#

I am working though this example of the Open XML SDK using F#
When I get to this line of code
sheet.Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart)
I am getting a null ref exception when I implement it like this:
sheet.Id.Value <- document.WorkbookPart.GetIdOfPart(worksheetPart)
Is there another way to assign that value? System.Reflection?
I got it working like this:
let sheet = new Sheet
(
Id = new StringValue(spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart)),
SheetId = UInt32Value.FromUInt32(1u),
Name = new StringValue("mySheet")
)
If You want to take a look to the entire sample translated to F#, it's here.
To clarify what's going on, the problem is that sheet.Id is initially null. If we look at the following:
sheet.Id.Value <- document.WorkbookPart.GetIdOfPart(worksheetPart)
The code tries to access the sheet.Id and invoke its Value property setter, but the Id itself is null. The answer posted by Grzegorz sets the value of the whole Id property - it's done in a construtor syntax, but it's equivalent to writing the following:
sheet.Id <- new StringValue(spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart))
This sets the whole Id property to a new StringValue instance.

NativeScript-Dev-Appium : UIElement.text() / UIElement.getAttribute("value") returns the automationText instead of the text displayed

I am using NativeScript-Dev-Appium#5.0.0 and wish to check for the text displayed on a label. I have automationText property assigned to the and use Driver.findElementByAccessibilityId(automationTextValue) to get the element. The element is found, but when I try to use the UIElement.text() / UIElement.getAttribute("value") on it, it returns the value of the automationText attribute instead of the actual displayed text. Is there any other method to do it because I can't find any.
Unfortunately, this is a limitation of NativeScript itself since when the automationText property is used, it will set all properties of the element like value, name, label etc. I would suggest you set the same text to automationText property and then you can access or test the element using something like this:
Using XPath:
const el = await driver.findElementByXPath("//*[#name=\"My automation text\"]");
For Android only
const el = await driver.findElementByText("My automation text");
const text = await el.getAttribute("text");
Use imageVerification types like:
await driver.compareRectangle
await driver.compareElement
await driver.compareScreen
Which is very convenient but the cons here is that this will require higher maintenance at some point.

Dart: how to dynamically set document's body's innerHTML

I see that Dart has a BodyElement class, and that it has an innerHTML property.
I also see that you can access the current document's body via window.document.body, however, there are no getter/setter methods for this body property.
So I'm trying to link the two together: how I dyamically set the current document's body's inner HTML? I'm looking for something like:
String html = "<p><h1>I'm dynamic</h1>";
window.document.body = bodyElementFactory.newBodyElement(html);
this should work for dart 1.14+
String html = "<p><h1>I'm dynamic</h1>";
querySelector('body').setInnerHtml(html);
Some options:
querySelector('body').appendHtml("<p><h1>I'm dynamic</h1>");
or
querySelector('body').innerHtml = "<p><h1>I'm dynamic</h1>";
document.body returns BodyElement. You could do the following if you wanted:
document.body.innerHtml = "<h1>I'm dynamic</h1>";

Call javascript in sharepoint custom field

I am creating a custom field in SharePoint 2007. I have seen other solutions where the current site URL was default value of a text field.
How can I get this current site URL?
I have got one answer whiches states that I shall use JavaScript, but where do I put the script?
I hope you can help.
BR
To answer 1
I am new to SharePoint and am not quiet sure where to put the java script. Normaly i just give the initial value to the field in the FieldEditor.cs file but how can I do this with the javascript?
Here follows a picute of my files.
I have tried to put it into FiledEditor.cs but this results in the value of myString is written in the top of the web page.
Here is my current code:
string myScript = "var currentUrl = document.URL; LabelLookupFieldTargetURLText.Text = currentUrl;";
Page.ClientScript.RegisterClientScriptBlock(LabelLookupFieldTargetURLText.GetType(), "LabelLookupFieldTargetURLTextJavaScript", myScript);
I found the answer my self. I don't need to use a java script. I can just use SPContext.Current.Site.Url
use javascript:
var nowUrl = document.URL;
yourTextfiled.value = nowUrl;
you can read this:http://www.w3schools.com/jsref/dom_obj_document.asp

Resources