LUA iup.text cursor trouble - lua

I am trying to use iup.text to create a textbox linked to a text file.
I want to display the text file in this textbox in real time.
local Visu = iup.text{
multiline="yes",
--rastersize="x60",
expand="yes",
readonly="yes",
--font="Times, Bold 12",
SCROLLBAR="YES",
AUTOHIDE="YES",
BGCOLOR="0 43 54",
fgcolor="255 255 255",
--maxsize="x1000",
}
function refresh_txt()
local f2 = io.open("txtfile.txt", "r")
if not f2 then
Visu.value = "Empty File"
else
Visu.value = f2:read("*a")
end
end
The problem is, when the textbox is just actualized by the function refresh_txt()` the cursor is put at the beginning of the showed text and not at the end of the text as I want.
So the text is constantly being refreshed and I can't scroll down because when I did it, the cursor goes to the first character of the first line.
I want an automatic vertical expand of the textbox when refreshed.
I think that the problem can be solved by some argument of iup.text, but I didn't found it.

To scroll down after changing the text use VisuQSPI.scrollto = "99999999:1".

Related

The Hyperlink is not displayed with blue and underline by use the Outlook add-in

I add a context menu item for new mail of Outlook, after select any text, use below method to add the Hyperlink. This works well in most conditions, but the hyperlink does not display with blue and underline in below two conditions. In the condition two below, the bullet or number is also deleted unexpectedly.
Two Condition:
1. No other character before and after the selected text, and there's lines(one or more, blank line or lines with characters)after the line which selected text is located.
2. Bullet or Number for the line which the selected text is located in. No other character before and after the selected text, and there's lines(one or more, blank line or lines with characters) after the line which selected text is located.
Code:
Outlook.Application myApplication = Globals.ThisAddIn.Application;
Outlook.Inspector inspector = myApplication.ActiveInspector();
Word.Document document = (Word.Document)inspector.WordEditor;
object selectedText = document.Application.Selection.Text.TrimEnd('\r');
object missing = Type.Missing;
object address = document.Application.Selection.Text.TrimEnd('\r');
document.Application.Selection.Hyperlinks.Add(document.Application.Selection.Range, ref address, ref missing, ref missing, ref selectedText, ref missing);
Any of you met this situation before? Why this happened? Any fix way/workaround?

How to keep the last character always visible in an input field on mobile safari?

I've a mobile web app and in it I've an input field type text.
I'm assigning it's value as
function setVal(str){
var item = $('#textField'),
string = item.val()+str;
item.val(string);
}
As the value is set programmaticaly without focusing on the field and typing on a keyboard, as the string gets longer than the width of the text-field, I can no longer see the new character additions as the text-field masks it.
You can see in the image above, the right most letter is 'K' (after j) but only part of it is visible.
How do I make sure that if the length of the string is more than the width of the text-field, the extra length goes left ward and the last letter is visible on the screen all the time?
Not exatly what you're looking for, but you can scroll left the text inside equally to the length of the input text, so the last character can always be visible.
var el = document.getElementById('textField');
el.focus();
el.scrollLeft = el.scrollWidth;
<input id="textField"></input>

Getting values out of text fields with UIAutomation

I'm trying to understand how UIAutomation can be used to perform automatic application tests, so I've created a temperature converter app that can be driven from the JavaScript interface. Here's the UI:
The top text field has an Accessibility label of "Celsius", similarly the bottom field has "Fahrenheit" as its Accessibility label. I'm trying to drive it through this script:
UIALogger.logStart("Test -40ºC == -40ºF");
var window = UIATarget.localTarget().frontMostApp().mainWindow();
var celsiusField = window.textFields()["Celsius"];
var fahrenheitField = window.textFields()["Fahrenheit"];
var convertButton = window.buttons()["Convert"];
celsiusField.setValue("-40");
convertButton.tap();
var fahrenheitValue = fahrenheitField.value();
if (fahrenheitValue == "-40.0") {
UIALogger.logPass("-40C == -40F");
} else {
UIALogger.logFail("-40C == " + fahrenheitValue + "F");
}
This correctly sets the text in the Celsius field to "-40", and when the button is tapped, the app updates the text in the Fahrenheit field to "-40.0". However, fahrenheitValue has the value "Fahrenheit" (the name/label of the text field), so the test fails. I wondered whether this was maybe a timing issue, so put in a one-second delay after the tap, which didn't change the behaviour.
Is it possible to get the text out of the text field and compare it with the expected value?
Is it getting "Fahrenheit" because that's the accessibility label or because it's the placeholder text?
It looks like value() might return the placeholder text. One workaround could be to modify the placeholder value once the user starts typing to set it to be the text the user entered and then reverting it to Fahrenheit when they delete? I assume that even when you call setValue it acts as it would when the UITextField delegate methods get called?
You could add a label to your view, update it and read it out.
Try hooking up the Accessibility Inspector to show what UIAutomation "sees" in your app. It might be that it's reading some stale values because of the way you set the values in your app.
One way of refreshing the values is to send an update event:
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);

Ruby/Rails - Properly Display/Format Text From The Text Area Form Control

I have a interesting problem. I have a :text field in my model with displays a large chunk of data, usually about three paragraphs.
When I enter the text in on the new view it might look like....
aaaaaaaaaaaaaaaaaaaaaaaaa.
bbbbbbbbbbbbbbbbbbbbbbbbbbbb.
ccccccccccccccccccccc.
Imagining that each a,b, or c is an individual paragraph.
With a space between the a, b, and c lines....(e.g. the line break that occurs when you press enter)
But when I display the very same data on the view, the line breaks are not recognized. The view seems to concatenate all the text into one big blurb and it displays like.....
aaaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccc.
But the line breaks are being recorded because going to edit shows the data in the format with the line breaks.
I thought about adding < p >'s into the text area and parsing the html on the view but that really isn't a good option since I dont want to require my users to insert html tags.
Is there something I'm missing to get the text area to display in the same fashion as it was entered?
Try simpleformat:
<%= simple_format(my_text_from_database) %>

I have one Textbox and inside the textbox i want the text which user cannot be deleted

i have one text box in which the text inside the text box should not be deleted and after the text only the cursor has to be placed
Ex:
For the textbox: "http://" should be available and the text which is in quotations cannot be deleted inside the textbox and the cursor should be after the quotations.
Thanks in advance,
Vara Prasad.M
add this to the input field:
onchange="testEdit(this)"
and have a javascript function that does something like this:
function testEdit(field) {
if (field.value.substring(0, 8) != "http://") {
field.value = "http://" + field.value.substring(8);
}
}
However, this is sloppy. The best way is to put the http:// in a label OUTSIDE the text box. If something is in a text box, it should be input. By putting that inside the text box, you will be confusing your users.
Good luck.

Resources