Rich text typing lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- carlangas · 2021-11-09 18:14 I need to type in using more than one colour and style in the same cell. The thing is I can put the data into the cell using the WriteTextAsHTML procedure, but once selected the cell, if I change the colour of the text, even when typing, the whole text uses this style, instead of the characters I type from then on. If I type in a TsCellEdit, the HTML code is shown, which is a bit of a mess. Anyway, if I use the associated shortcuts to change the style, the same happens: the whole cell gets that style. What I aim at is the usual behaviour in Libreoffice Calc, where you can change the partial font style as you type and edit it afterwards so that a cell consists of text in multiple colours and styles. Is there an 'easy' way of achieving this? I managed to almost solve it by using a TRichMemo, but there must be a simpler way not involving so complicated actions. Thanks for your help. ---------------------------------------------------------------------- wp · 2021-11-09 18:41 Quote from: carlangas on November 09, 2021, 07:14:23 pmIs there an 'easy' way of achieving this? No. The grid cell painting was built having that html thing in mind. It requires some programming. The TCell record in the underlying worksheet displayed in the grid contains the cell text as well as an array of "rich text parameters", these are records consisting of the character position at which the font changes and the index of the font to be used after this position. So, you must rewrite the cell editor in a way that it remembers the positions where you change the font. The real problem, however, is that the LCL edit controls (TEdit, TMemo) do not support changing the font locally within their text. You could probably build a new cell editor based on TRichMemo - but this would create a dependence of the fpspreadsheet controls on another library which I try to avoid. So, chances are not good that I will add something like this to fpspreadsheet. ---------------------------------------------------------------------- skalogryz · 2021-11-09 19:54 Quote from: wp on November 09, 2021, 07:41:48 pmYou could probably build a new cell editor based on TRichMemo - but this would create a dependence of the fpspreadsheet controls on another library which I try to avoid.Unless TRichMemo moves into the official LCL. ---------------------------------------------------------------------- wp · 2021-11-09 20:48 yes ---------------------------------------------------------------------- carlangas · 2021-11-09 21:10 I see. So, being TsCellEdit a descendant of TEdit, it is, in principle, unable to display what I want. I thought it was a kind of standalone cell and I could access its properties, including the TCell record, which by the way, I don't know how to reach. ---------------------------------------------------------------------- wp · 2021-11-13 22:14 I began experimenting with a TRichMemo as grid cell editor (https://github.com/wp-xyz/FPSpreadsheet_RichMemo). Since I want to keep third-party packages out of the basic fpspreadsheet I'll add another package for TRichMemo integration to be installed additionally. But this will be in the future... ATM, being far from complete, but the project does not look too complicated so far. Be patient.