Recent

Author Topic: A flag problem? [SOLVED]  (Read 449 times)

Badger

  • Full Member
  • ***
  • Posts: 144
A flag problem? [SOLVED]
« on: June 07, 2023, 07:15:58 am »
I have a StringGrid for which I test input with OnEditingDone and, if there is a potential problem, a MessageDlg asks if the user wishes to continue with the input or revert to original cell contents. There is also a Save button on the Form.

My problem is this.  If the user enters a suspect string then presses Save while the focus is still on the last grid cell, the flow passes through the EditingDone procedure and triggers the MessageDlg but the Save procedure doesn't subsequently fire.  Non-flagged input with the focus on the last cell works fine despite all inputs being checked by the EditingDone procedure.  It seems that the opening and responding to the MessageDlg prevents the Save from being called.

My program is large so I have written the attached files (.txt is th .lfm file) to demonstrate. The grid will take any input and the button changes the colour of the square at any time.  If the input is an 'a' and the focus is left on the grid cell and the colour change button is pressed, the messagedlg fires but the square doesn't change colour.  But if the input does not contain an 'a' then the colour button fires despite the flow going through the editingdone procedure.

The problem seems to be the calling of the messagedlg

Am I ding something wrong (probably) or is it a bug? Any solution?
« Last Edit: June 07, 2023, 09:34:33 am by Badger »
Badger
(A bad tempered, grumpy animal that sleeps most of the winter!)

If at first you don't succeed - you're running about average!

I'm using Windows 10 Lazarus v2.4.4  FPC 3.2.2   Win 32/64

paweld

  • Hero Member
  • *****
  • Posts: 969
Re: A flag problem?
« Reply #1 on: June 07, 2023, 08:07:52 am »
A ButtonClick procedure is not called yet, because the automatic checking of the cell contents is called from the StringGrid context - showing the dialog remove focus from Button1 and the on Click event is not triggered.
But this can be solved in another way - an example in attachment
Best regards / Pozdrawiam
paweld

Badger

  • Full Member
  • ***
  • Posts: 144
Re: A flag problem?
« Reply #2 on: June 07, 2023, 09:33:21 am »
Many Thanks!!

So easy when you know how.

So much to learn - so little time!
Badger
(A bad tempered, grumpy animal that sleeps most of the winter!)

If at first you don't succeed - you're running about average!

I'm using Windows 10 Lazarus v2.4.4  FPC 3.2.2   Win 32/64

 

TinyPortal © 2005-2018