Recent

Author Topic: Undo and CanUndo in TMemo  (Read 2533 times)

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Undo and CanUndo in TMemo
« on: September 01, 2018, 08:00:30 pm »
The environment
  • Lazarus 1.8.4 (GTK2) / FPC 3.0.4
  • Kubuntu 14.04 / Ubuntu 10.10
The program
It's a very simple program: just a form with a TMainMenu, a TMemo, some actions and little else. In the main menu there is---among others---a top-level item "Edit" with a submenu of items "Undo, "Cut", "Copy", "Paste", etc.

The handlers for items "Edit" and "Undo" are these:
Code: Pascal  [Select][+][-]
  1. procedure TMain.itEditClick(Sender: TObject);
  2. begin
  3.   itEditUndo.Enabled := Memo.CanUndo;
  4.   {itEditRedo.Enabled := False;}{ No redo for the wicked!? }
  5.   itEditCut.Enabled := (Memo.SelLength > 0) and (not Memo.ReadOnly);
  6.   itEditCopy.Enabled := (Memo.SelLength > 0);
  7.   itEditPaste.Enabled := (not Memo.ReadOnly) and
  8.                          Clipboard.HasFormat(CF_Text);
  9.   {... etc. sniped for the forum ...}
  10. end;
  11.  
  12. procedure TMain.itEditUndoClick(Sender: TObject);
  13. begin
  14.   Memo.Undo;
  15. end;

The problem
Whatever I do: type, paste, delete, etc. Memo.CanUndo is always false.
Even if I comment out the line:

    itEditUndo.Enabled := Memo.CanUndo;

and keep the item itEditUndo always enabled, Memo.Undo, of course, does nothing.

The question(s)
Is this some bug (in GTK, perhaps)? As designed? Fixed somewhere? Can't (or will never) be fixed? Am I going mad?

The notes
I seem to remember that this worked on Windows, but I can't test ATM because my Windows boxes are undergoing surgery.

Any help, anyone?
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus
Re: Undo and CanUndo in TMemo
« Reply #1 on: September 01, 2018, 08:32:22 pm »

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Undo and CanUndo in TMemo
« Reply #2 on: September 01, 2018, 09:46:04 pm »
Thanks, Handoko; I forgot the first rule of posting: search before doing anything else  :-[

So the answer is: it's a well known bug about which, apparently, nobody cares enough to fix properly.

Well, I'll see what I can do to implement something like it.

Thanks again!
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Undo and CanUndo in TMemo
« Reply #3 on: September 02, 2018, 12:46:30 am »
Thanks, Handoko; I forgot the first rule of posting: search before doing anything else  :-[

So the answer is: it's a well known bug about which, apparently, nobody cares enough to fix properly.
I'm under the impression that gtk is in the process of phasing out in favor of gtk 3. In which case I would try to test with gtk3 and see if you can convince the authors to add it on gtk3 now that its still under development.
Well, I'll see what I can do to implement something like it.

Thanks again!
https://forum.lazarus.freepascal.org/index.php/topic,40205.0.html here this should get you there faster.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Undo and CanUndo in TMemo
« Reply #4 on: September 02, 2018, 01:59:58 am »
Alas! I need it on Gtk2 too, so it's me for the grinding-wheel ... although your link may make it less "grinding".
Thanks, Taaz  :)
« Last Edit: September 02, 2018, 02:06:23 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018