Recent

Author Topic: TMemo selection after focus loss  (Read 8431 times)

sfeinst

  • Full Member
  • ***
  • Posts: 186
TMemo selection after focus loss
« on: May 08, 2010, 03:25:06 pm »
I've noticed with the apps I've built, that when I select something in a TMemo and the focus is lost (a dialog is displayed for example), the selection disappears.  I've tried this in other apps (notepad for example) and the selection stays on those.  Is this just how TMemo works or is there a property I can set to keep showing the selection?
« Last Edit: May 13, 2010, 12:33:08 pm by sfeinst »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: TMemo selection after focis loss
« Reply #1 on: May 08, 2010, 06:04:11 pm »
Set the property HideSelection to False.

sfeinst

  • Full Member
  • ***
  • Posts: 186
Re: TMemo selection after focis loss
« Reply #2 on: May 10, 2010, 01:49:53 am »
Set the property HideSelection to False.

On what control?  I looked at TMemo and I do not see a HideSelection property.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8744
  • Debugger - SynEdit - and more
    • wiki
Re: TMemo selection after focis loss
« Reply #3 on: May 10, 2010, 02:02:52 am »
What version of lazarus do you have?

It exists in the latest SVN version.

Maybe it is not published in older Lazarus, then you may still be able to set it from within your code

Memo1.HideSelection := False;

sfeinst

  • Full Member
  • ***
  • Posts: 186
Re: TMemo selection after focis loss
« Reply #4 on: May 10, 2010, 01:23:36 pm »
What version of lazarus do you have?

It exists in the latest SVN version.

Maybe it is not published in older Lazarus, then you may still be able to set it from within your code

Memo1.HideSelection := False;

I am running version 0.9.28.2 beta under Windows.  Under Linux, I am running the same (I think - not at the machine to look at the actual version).  I tried in code, but, that option is not available.  So it looks like I will either need to pull from SVN or wait until a newer version becomes available from Linux distribution.

sfeinst

  • Full Member
  • ***
  • Posts: 186
Re: TMemo selection after focus loss
« Reply #5 on: May 13, 2010, 12:35:07 pm »
OK.  I downloaded the latest from trunk (0.9.29) and I see there is now a HideSelection property.  I tried setting the property in the object browser and in code.  I tested the value with a showmessage and see it is set to false.  But it does not seem to work for me (testing under Windows).  When the tmemo loses focus, the selection disappears.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8744
  • Debugger - SynEdit - and more
    • wiki
Re: TMemo selection after focus loss
« Reply #6 on: May 13, 2010, 01:39:14 pm »
Indeed, the feature got broken...

Now that's a catch 22. You have no choice but to use the daily snapshot, but the daily snapshot is broken... (snapshots are explicitly marked as having a high risk of getting broken)

anyway, will be fixed in tomorrows snapshot. (or svn right now)

Or if you do not want to wait, apply below patch:
Code: [Select]
Index: win32wsstdctrls.pp
===================================================================
--- win32wsstdctrls.pp (revision 25364)
+++ win32wsstdctrls.pp (revision 25365)
@@ -1249,6 +1249,8 @@
       Flags := Flags or ES_AUTOHSCROLL;
     if ACustomMemo.BorderStyle = bsSingle then
       FlagsEx := FlagsEx or WS_EX_CLIENTEDGE;
+    if not ACustomMemo.HideSelection then
+      Flags := Flags or ES_NOHIDESEL;
     pClassName := @EditClsName[0];
     WindowTitle := StrCaption;
   end;

sfeinst

  • Full Member
  • ***
  • Posts: 186
Re: TMemo selection after focus loss
« Reply #7 on: May 13, 2010, 03:23:20 pm »
Pulled from SVN.  Works fine now thanks.

 

TinyPortal © 2005-2018