How to set cursor position at the end in Extjs HtmlEditor - html-editor

Is there a way to set cursor position at the end in Extjs HtmlEditor? I did not find any solution for this and I dont want to insert text but only need default cursor at the end of text on focus.
any solution will be appreciated.

Apparently it doesn't have a direct way to do this, but you can do it like this:
editor.getDoc().body.innerHTML = '<div style="text-align:right;">&#8203</div>';
editor.updateLayout();
editor.focus();

Related

Lazarus button toggle mechanism

I wrote a little tool in Lazarus to use it as a launcher for some games of mine, all of this is done by cmd scripts which are linked to the press of a button.
Now I'm looking for two modifications to my tool, but since I'm not very talented when it comes to programming, I hope somebody can help me.
The first thing I'm looking for is to split the TButton caption into two lines. I have tried to do it over the GUI but did not find a solution for this.
The second thing I want to do is to change the caption and the function of a button by pressing on it. For example Button1 has the caption Enable Enhancements, which runs the script enhancements_on.bat. After I press the button, I want it to change the caption to Disable Enhancements, in order that the script enhancements_off.bat will run on next press.
Is this possible? if yes, how do you do it?
I've find out. In case anyone needs a feature like this, use a togglebox and the following code:
procedure TForm1.ToggleBox1Change(Sender: TObject);
begin
if ToggleBox1.Checked then
begin
ToggleBox1.Caption:='Mods aktiviert.'
ShellExecute(0,nil, PChar('cmd'),PChar('/c "start enhancements_on.bat"'),nil,1)
end
else ToggleBox1.Caption:='Mods deaktiviert.';
ShellExecute(0,nil, PChar('cmd'),PChar('/c "start enhancements_off.bat"'),nil,1)
end;
The first thing I'm looking for is to split the TButton caption into two lines.
Simply set the caption of the Togglebox at runtime, e.g. in the OnCreate event of the form and use LineEnding to split the lines.
Togglebox1.Caption := 'Line 1' + LineEnding + 'Line 2';
Note that this works only with TTogglebox, not with TButton.

Selecting the text within a TStringGrid cell

The component I use is a descendant of TStringGrid, called TDataGrid (which can be found on Torry). Unfortunately, it has a small bug which doesn't seem to be present in the original TStringGrid component. I have the options goEditing and goAlwaysShowEditor both enabled, so I'm expecting the text of a cell to be selected when the control receives input focus. But in the case of TDataGrid this doesn't happen if I press TAB to move from one control into the grid control. It receives input focus, but nothing is selected, and the caret isn't even visible. Obviously, this is very misleading for a user.
The original TStringGrid component has similar inconsistencies, where if you have goAlwaysShowEditor enabled, there is always one cell with its text "exposed" (focused, sort of, even if the grid control itself doesn't have focus), so if you left-click in that cell, it also won't select the text, just enable a caret. I have been able to get around this however, by simply disabling goAlwaysShowEditor when the grid control doesn't have focus and subsequently enabling it when the grid receives focus.
So does a TStringGrid have any way of selecting the text of a cell? I know how to set the focus to a cell, but I haven't figured out a way to actually select the text. Really would appreciate any ideas to get around this!
FWIW, I'm using Delphi 10.3
I've found one solution that actually seems to work, but it only handles the very specific scenario when you TAB into the grid control and there may be other cases that need to be handled..
So, controlling the selection of the text within a cell IS possible, but it will not work if you try to control it during the OnEnter event. So instead, I've had to resort to checking for TAB in the OnKeyUp event, where it will work.
You need to expose protected members of a TStringGrid to access the appropriate methods. It's not the prettiest solution, but it works at least...
type TStringGridHelper = class helper for TStringGrid
procedure HHideEditor;
procedure HShowEditor;
end;
procedure TDataGridHelper.HHideEditor;
begin
HideEditor;
end;
procedure TDataGridHelper.HShowEditor;
begin
ShowEditor;
end;
And in the OnKeyUp event handler...
if Key = VK_TAB then begin
StringGrid.HHideEditor;
StringGrid.HShowEditor;
end;

Change VB6 cell properties on runtime?

I have a table with a foo number of rows and bar number of columns.
What i'd like is for the selected cell to really appear as being selected.
At the moment the leftmost cell gets a red text to mark it's being selected.
What i'd llike is for the lines at the top and bottom of the cell to get bigger to really show that the cell is selected.
I've looked at the following but without success.
grd.row = aRow
grd.col = aCol
' Therafter i try to change the following:
grd.CellBorderColor = 255 ' Original value does not change
grd.CellBorderStyle = 2 ' Original value does not change
EDIT:
I found out that previously named properties are read only.. What can i do?
Any tips and/or pointers in the right direction will be highly appreciated, thanks for reading.
This particular grid. Called vaSpread or fpSpread needs a specific line to execute.
For executing changes to grid style you need to call grid.action = 13 after you've written the visual changes to the grid.

apps-script TextArea: can't scroll text into view with setCursorPos

I have a long text in a gas TextArea and I want to scroll a line of text into view. I tried several solutions (setCursorPos, setSelectionRange), but the text is always displayed at the top; i.e. it never scrolls down to the position I want...
I did notice that the doc says: "This will only work when the TextArea is attached to the document and not hidden.". That shouldn't really apply in my case (I want the app to pop up at the specific position...), but I tried to set it before and after the app is displayed.
Here is the code.
....
var cursorPos=15;//just a test...
var fileString = "a very long text that I'm not putting in here....";
var mytextArea=myapp.createTextArea().setValue(fileString).setSize("100%","100%").setName("TextArea").setId("TextArea");
myapp.add(mytextArea.setCursorPos(cursorPos));
var doc=SpreadsheetApp.getActive();
doc.show(myapp);
myapp.getElementById("TextArea").setFocus().setCursorPos(cursorPos);
I must be doing something obviously wrong. Any suggestions?
Issue is here: http://code.google.com/p/google-apps-script-issues/issues/detail?id=1635
The issue response was: "Unfortunately this is a limitation of the underlying GWT technology" :( So no fix any time soon... : i.e setCursorPos(cursorPos) does nothing...
Have you tried wrapping the text area in a scroll panel and setting the position of the scroll panel?

Hide Cursor on Form in VB6

I'm currently using the ShowCursor API call to hide a cursor for an application after a set period of inactivity. This works fine, except that the cursor is hidden over both the menus and status bar (which I don't want). I'm also using a Form_MouseMove to switch the cursor back on, but this doesn't work over the menus or status bar.
Is there a clever way to target hiding the cursor to just on the Form (supplying a hWnd for example, to some API call or other)?
I've tried this on my form:
With Me
.MouseIcon = LoadPicture("C:\Windows\Cursors\blank.cur")
.MousePointer = vbCustom
End With
having downloaded a blank.cur file off the internet.
The cursor disappears over the form, but is still visible over the menu bar.
Isn't there something like Form1.MousePointer = vbHourGlass property?
Yes, here.

Resources