Hi how do you group chats in date order
Hi,
What do you mean by grouping in date order?
The underlying TTMSFNCTableView
has Categories
but that was not exposed in TTMSFNCChat
yet.
Yes if categories was exposed that would sort this problem out.
We'll put this on our todo list to see how we can best expose it.
Thanks
Also when you use AddMessage to add messages the control does not auto Scroll To Bottom
The scrolling issue had been reported earlier and we applied a fix for it. The next update will contain the necessary changes.
Thanks
A very small thing. Since I use a database when the send button I have to update the record that the send button adds with the one from the db. If you are looking at the chat maybe a property not to add to collection.
I'm not sure I fully understand your question. Do you want to avoid to add a chat message to the ChatMessages collection? Then they won't be drawn, the chat items are drawn based on the collection content.
I populate the chats from the database with addmessage. I am talking about the send button which adds to the collection and has a call to add to db. The collection is refreshed from the db so that messages from other entities are added to the collection. I am not using the json calls
It's still not clear. The TTMSFNCChat does not do any interaction with any database, that is all implemented by you.
If by clicking the Send button you refresh your database based on the collection items then you need to make sure the refresh does not cause additional items to be added to TTMSFNCChat. But the Send button needs to add and item to the ChatMessages collection, otherwise the chat message won't be visible.
Exactly the chat is refreshed from the db but also added to the collection from the send button. The items should only be added to the collection from the db not on send as well.
The OnBeforeSendMessage
event has an AAllow
parameter that let's you prevent the messages to be added to the collection. This however also triggers for messages added using AddMessage
so you'll need to implement OnSendButtonClick
too to set a flag. Something like this:
procedure TForm3.FormCreate(Sender: TObject);
begin
FSendButtonClick := False;
end;
procedure TForm3.TMSFNCChat1BeforeSendMessage(Sender: TObject;
var AText: string; var AAllow: Boolean);
begin
if FSendButtonClick then
begin
AAllow := False;
//send AText to DB, sanitize first if necessary
TMSFNCChat1.Memo.Lines.Clear;
FSendButtonClick := False;
end;
end;
procedure TForm3.TMSFNCChat1SendButtonClick(Sender: TObject);
begin
FSendButtonClick := True;
end;
thank you
On mobile the keyboard covers the message box. I have used a vertical scroll box and the onfocus event on the main form but am having problems with having to click the send button twice. Is there a better way of doing the moving of the messagebox up to stop the keyboard covering it
Hi,
No, the way to do this is to use a vertical scroll box on mobile. We tested this with the ScrollableFromDemo, and while not consistently, we can also see that sometimes the message is not added to the collection before the keyboard closes. Most likely the OnClick
event cannot complete as the view changes, so it's worth a try to couple the sending to the OnMouseDown
event instead.
Not sure about your implementation but just for testing, you could try:
implementation
type
TTMSFNCChatOpen = class(TTMSFNCChat);
procedure TFormMain.FormCreate(Sender: TObject);
begin
TMSFNCChat1.SendButton.OnMouseDown := HandleMouseDown;
//...
end;
procedure TFormMain.HandleMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
TTMSFNCChatOpen(TMSFNCChat1).DoToolbarButtonClick(TMSFNCChat1.SendButton);
end;
If you can confirm this works for you, we can introduce an additional property to toggle the sending between OnMouseDown
and OnClick
. Then it'll be just a matter of setting that property for Android to allow sending messages as soon as the button's OnMouseDown
is triggered.
Thanks I also used the ScrollableFromDemo.
I will try your suggestion
It works perfectly in my tests.
Have you manage to expose the `TMSFNCTableView Categories in chat yet?
Thank you for confirming, we'll look to add a property that will allow to switch between when the message sending is triggered.
Not yet, but we'll allocate time on it soon.
Thank You