Title: Set Scroll Position in Text Edit Post by: Anderson P. on September 18, 2014, 03:16:11 pm Is it possible to set the scroll position of a text edit?
In a practical way, i have in my screen a text edit with a large amount of text, i want the screen to open with the text edit scrolled to the bottom. Is this possible? Title: Re: Set Scroll Position in Text Edit Post by: Snorri B. on September 18, 2014, 04:30:35 pm Have you tried fgl_dialog_setcursor(pos)?
Title: Re: Set Scroll Position in Text Edit Post by: Anderson P. on September 18, 2014, 04:53:51 pm He have indeed tried "fgl_dialog_setcursor", but we can only use this command in a "on action" block during a input in the text edit, right? And we can't use this in the "before input" for example.
I will try to give you a better explanation of the situation, i have in my screen a "edit" field called "message" and a "text edit" field called "chat". The user type the message and this is appended to the chat. When the message is appended to the chat, the chat must scroll to the bottom. Title: Re: Set Scroll Position in Text Edit Post by: Snorri B. on September 18, 2014, 04:57:15 pm It works for us like this:
before field l call fgl_dialog_setcursor(l_stad) before field haus call fgl_dialog_setcursor(haus_stad) after field l let l_stad = fgl_dialog_getcursor() after field haus let haus_stad = fgl_dialog_getcursor() Title: Re: Set Scroll Position in Text Edit Post by: Anderson P. on September 18, 2014, 07:00:58 pm Hi Snorri
Here is our test Code
So, it's supposed to work like this: user inputs the message and click "send", after sending the program append the message to the chat and exit the message input, so i can make a input in the chat window do be able to call the fgl_dialog_setcursor, exit input and go back to the message input in the while loop. If i remove the "exit input" from the input g_chat block, it's all nice, the cursor goes to the end and the text edit scrolls! The problem is after the exit input, when i exit the input the scroll go back to the top :( Title: Re: Set Scroll Position in Text Edit Post by: Snorri B. on September 18, 2014, 07:57:27 pm Have you tried to put this into a DIALOG block and position the cursor BEFORE DIALOG?
Title: Re: Set Scroll Position in Text Edit Post by: Anderson P. on September 18, 2014, 08:20:55 pm I guess i can't use this command in the "before dialog" cause this way Genero will not know with field's cursor it show position, but i have indeed tried to put this command in the "before input" of my above example.
I replaced the "before field s_chat" for "before input" and called "fgl_dialog_setcursor" at the before input block, the result? Code
But the bigger problem is that this application must work in GDC and also on GWC and i have found out that the command "fgl_dialog_setcursor" does not work in GWC (HTML5 version), the cursor simply don't move... Even if i have just an input and put the "fgl_dialog_setcursor" in the before field, witch works perfectly on GDC, in GWC the cursor simply don't move... Title: Re: Set Scroll Position in Text Edit Post by: Reuben B. on September 19, 2014, 12:12:45 am One of the good things about GWC is that you can code in functionality that may be missing.
So for something like this, you can google and find pages such as ... http://stackoverflow.com/questions/9170670/how-do-i-set-textarea-scroll-bar-to-bottom-as-a-default ... which gives a nice simple technique. Code
So then you can create your own frontcall as per https://4js.com/online_documentation/fjs-gas-manual-html/#c_gas_front_end_call_001.html e.g. Code
(for a quick hack, add to csf.js but I'd recommend your own .js file rather than editing csf.js) and then call it from your 4gl. So my quick test... Code
Code
I was getting the behaviour you were after. The only thing I'd have to change is note in the 4gl above, I've hard-coded the Id attribute (ge118) (that number may vary when you run). There should be a way ( I just can't recall off top of my head) where you can pass the fieldname e.g. "formonly.conversation", to the front-call and have some javascript to return the value of the appropriate Id. Reuben Title: Re: Set Scroll Position in Text Edit Post by: Sebastien F. on September 19, 2014, 09:04:31 am Hello,
Just a remark: Instead of using 2 textedits with set cursor function and extend front-ends with custom code, did you consider to implement this form with a DIALOG block, mixing a INPUT and a DISPLAY ARRAY? The INPUT would be used to enter the message text and the DISPLAY ARRAY would show the history of the chat. When clicking on the DISPLAY ARRAY rows, just re-display the text in the INPUT field. If you want to deny modification of sent messages, disable the INPUT field for existing messages. With DISPLAY ARRAY controlling the chat history, the user can easily move back and forth, and you can scroll by program to the end of the list with DIALOG.setCurrentRow(). Seb Title: Re: Set Scroll Position in Text Edit Post by: Anderson P. on September 19, 2014, 01:19:01 pm Hey guys, thanks for the reply.
Reuben, that was a good solution that might work, mixing javascript with genero to manipulate the interface in GWC, but that solution was a bit more complex than what i was expecting to do. Actually i liked the Sebastien solution, using a table to show the chat history. We tried that and it worked great! Just one more thing, we also use HTML formating in our messages, so i created the display array of Text Edit component and applied the flowing style at the text edit: Code
Great on desktop, but in GWC HTML5 the text edit become huge, forcing me to use an "edit" instead of "text edit", but now the edit does not support the textFormat style... Any ideas? Title: Re: Set Scroll Position in Text Edit Post by: Reuben B. on September 22, 2014, 10:55:47 pm Is it an option to use LABEL instead of TEXTEDIT as that does support textFormat style as well.
Title: Re: Set Scroll Position in Text Edit Post by: John T. on September 23, 2014, 02:09:54 am Hi,
I am not sure if you mean the size of the text in the TextEdit, or the container of the TextEdit. With HTML5 client and a TextEdit, using textFormat of HTML, we end up with an iFrame. Therefore styles are not inherited. Very little styling is applied within the iFrame by the GWC. By default we can have quite large text (presumably the default of 16px), so we just wrap a bit of inline styling around the text to get the size we want. The container size for the TextEdit we do seem to be able to manipulate by changing the font-size style in the .4st file. The div containing the iFrame seems to set the container size. Not really sure if this answers your question, but it may help. John Title: Re: Set Scroll Position in Text Edit Post by: Anderson P. on September 23, 2014, 01:18:09 pm Hi John!
Actually, i meant the size of the TextEdit container. We tried out Reuben's solution to activate HTML in a label and it worked perfectly! So we created a display array with labels inside and used a function to break the string into an array. This way we archived our goal, simple and clean. Here is the style we used: Code
Thank you very much for all the help and attention. |