Recent

Author Topic: OnMouseDown event  (Read 21730 times)

RW1962

  • New Member
  • *
  • Posts: 41
Re: OnMouseDown event
« Reply #15 on: January 28, 2024, 06:17:11 pm »
What are you calling "the form"? I renamed RichMemo1 to PageMemo, which is what I call RichMemo. It could not recognize RichMemo1.

So FormMouseDown did nothing.

RichMemo1MouseDown fired on LEFT, MIDDLE, and RIGHT. But it did nothing with both EXtRA buttons.


Code: Pascal  [Select][+][-]
  1. // by rvk  ** TRichMemo1(Sender).Lines.Add only works in the TRichMemo.OnMouseDown **
  2. procedure TCmdForm.FormMouseDown(Sender: TObject; Button: TMouseButton;
  3.                                Shift: TShiftState; X, Y: Integer);
  4. begin
  5.   case Button of
  6.     mbLeft: PageMemo.Lines.Add('form Left');
  7.     mbRight: PageMemo.Lines.Add('form Right');
  8.     mbMiddle: PageMemo.Lines.Add('form Middle');
  9.     mbExtra1: PageMemo.Lines.Add('form Extra1');
  10.     mbExtra2: PageMemo.Lines.Add('form Extra2');
  11.   end;
  12. end;
  13.  
  14. // by rvk  ** TRichMemo(Sender).Lines.Add only works in the TRichMemo.OnMouseDown **
  15. procedure TCmdForm.RichMemo1MouseDown(Sender: TObject; Button: TMouseButton;
  16.                                       Shift: TShiftState; X,Y: Integer);
  17. begin
  18.   case Button of
  19.     mbLeft: TRichMemo(Sender).Lines.Add('Left');  // ** FIRED **
  20.     mbRight: TRichMemo(Sender).Lines.Add('Right');  // ** FIRED **
  21.     mbMiddle: TRichMemo(Sender).Lines.Add('Middle');  // ** FIRED **
  22.  
  23.     mbExtra1: TRichMemo(Sender).Lines.Add('Extra1');  // ** NOTHING **
  24.     mbExtra2: TRichMemo(Sender).Lines.Add('Extra2');  // ** NOTHING **
  25.   end;
  26. end;
  27.  

rvk

  • Hero Member
  • *****
  • Posts: 6953
Re: OnMouseDown event
« Reply #16 on: January 28, 2024, 06:31:20 pm »
If you put a TRichMemo on the form is its default name is RichMemo1. That's what I used in my test program.

For the TForm.OnMouseDown I meant the event OnMouseDown of the form itself. If you click the mouse anywhere in the form where there is no component (so empty space) it should also fire. If it doesn't fire you know it's not TRichMemo at fault but your Lazarus install or mousedriver.

What mouse do you have and what did you test if the driver recognized those extra buttons (which buttons do you consider extra. I used the side buttons, left side normally used for back/forward browser.)

RW1962

  • New Member
  • *
  • Posts: 41
Re: OnMouseDown event
« Reply #17 on: January 28, 2024, 07:59:23 pm »
I use the Logitech M-570 trackball.

I have switched to another of the same make and model (it was my backup mouse).

I get the same behavior. 1 thru 3 fire, and 4 & 5 do not.

Plus, throughout this exchange I have always been able to use the 4 & 5 buttons with several editors, pdf reader, this Forum site and all websites. This only happens with RichMemo.

Rick

rvk

  • Hero Member
  • *****
  • Posts: 6953
Re: OnMouseDown event
« Reply #18 on: January 28, 2024, 08:07:27 pm »
This only happens with RichMemo.
Do you mean the event does fire correctly for TForm.OnMouseDown when you use it in a blanc space on the form??? (Like I showed in the testcode with FormMouseDown event)


RW1962

  • New Member
  • *
  • Posts: 41
Re: OnMouseDown event
« Reply #19 on: January 28, 2024, 08:25:12 pm »
I still don't know what you are calling the FORM. Is it the TRichMemo control? That is all I have been testing with, because I want it to use the 4 & 5 buttons.

If the FORM is the host to the TRichMemo control, I don't have any idea on how I would make that happen.

Both of your procedures will fire on 1 thru 3, and neither of them will fire firing with the 4 & 5 buttons. They give the same results as had my original procedure.

Rick


rvk

  • Hero Member
  • *****
  • Posts: 6953
Re: OnMouseDown event
« Reply #20 on: January 28, 2024, 08:34:37 pm »
I still don't know what you are calling the FORM.
I just want you to try the procedure with form itself.
You say its TRichMemo at fault.
I say its lazarus itself or something else, but not TRichMemo.

Create an empty project. Put in a trichmemo or tmemo
Click the events for the Form (where you also define OnCreateForm)
Now double click the OnMouseDown (so for the Form1 itself).
Paste in the code for FormMouseDown and test your mouse by clicking in the form.
Do the extra1 and 2 fire?

If not then it's Lazarus itself that's not passing all the buttons.
That has nothing to do with TRichMemo itself.

So basically my question is... Can you get extra1 and 2 working at all in Lazarus with any component at all (for example the form itself as explained above)?

rvk

  • Hero Member
  • *****
  • Posts: 6953
Re: OnMouseDown event
« Reply #21 on: January 28, 2024, 08:37:24 pm »
Both of your procedures will fire on 1 thru 3, and neither of them will fire firing with the 4 & 5 buttons. They give the same results as had my original procedure.
If the event for TForm MouseDown works only for 1-3 and not the extra then it's not a problem of TRichMemo because you can't even get extra1 to work with Lazarus Form. So there is something else that's causes this (not TRichMemo but the whole of Lazarus can't get extra1).

rvk

  • Hero Member
  • *****
  • Posts: 6953
Re: OnMouseDown event
« Reply #22 on: January 28, 2024, 08:40:00 pm »
BTW. I'm using the 4 and 5 button from the mouse below. And they work fine.

Can you test a mouse like that?

(Although 4 and 5 do seem the same on the Logitech M570.)

On Lazarus 3.0 it just works for me.
« Last Edit: January 28, 2024, 08:42:50 pm by rvk »

Thaddy

  • Hero Member
  • *****
  • Posts: 18781
  • To Europe: simply sell USA bonds: dollar collapses
Re: OnMouseDown event
« Reply #23 on: January 28, 2024, 08:51:04 pm »
OnMouseDown use OnMouseUp here.
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

RW1962

  • New Member
  • *
  • Posts: 41
Re: OnMouseDown event
« Reply #24 on: January 28, 2024, 08:56:29 pm »
I have only used trackballs. I have never used mice.

It isn't the mouse. It fires on all 5 buttons with any other software and website.

I did a fresh TRichmemo, but I did not create the procedure by double-clicking the OnMouseDown event. So I will get back to you on that. But I have been doing this for 10 hours, so I will get back to you tomorrow.

@Thaddy, I tried the MouseUp procedure ... it did the same stuff.

Rick

rvk

  • Hero Member
  • *****
  • Posts: 6953
Re: OnMouseDown event
« Reply #25 on: January 28, 2024, 09:04:26 pm »
I did a fresh TRichmemo, but I did not create the procedure by double-clicking the OnMouseDown event. So I will get back to you on that.
As long as you connect the event with the onmousedown in the object inspector. But because it works for button left and right I imagine you did that.

Now also connect the event for Form1 OnMouseDown so you can see if it works on the form itself. If it also only works for button left and right on the form, but not for mbextra1 and 2 then it seems a problem in the Lazarus installation. Make sure you have the latest 3.0 version then.

I'll speak to you tomorrow.

RW1962

  • New Member
  • *
  • Posts: 41
Re: OnMouseDown event
« Reply #26 on: January 29, 2024, 02:10:49 pm »
Here is the code.

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, RichMemo;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     RichMemo1: TRichMemo;
  16.  
  17.     procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
  18.                               Shift: TShiftState; X, Y: Integer);
  19.  
  20.     procedure SenderMouseDown(Sender: TObject; Button: TMouseButton;
  21.                               Shift: TShiftState; X,Y: Integer);
  22.   private
  23.  
  24.   public
  25.  
  26.   end;
  27.  
  28. var
  29.   Form1: TForm1;
  30.  
  31. implementation
  32.  
  33. {$R *.lfm}
  34.  
  35. { TForm1 }
  36.  
  37. procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  38.   Shift: TShiftState; X, Y: Integer);
  39. begin
  40.   case Button of
  41.     mbLeft: RichMemo1.Lines.Add('Form Left');
  42.     mbRight: RichMemo1.Lines.Add('Form Right');
  43.     mbMiddle: RichMemo1.Lines.Add('Form Middle');
  44.     mbExtra1: RichMemo1.Lines.Add('Form Extra1');
  45.     mbExtra2: RichMemo1.Lines.Add('Form Extra2');
  46.   end;
  47. end;
  48.  
  49. procedure TForm1.RichMemo1MouseUp(Sender: TObject; Button: TMouseButton;
  50.   Shift: TShiftState; X, Y: Integer);
  51. begin
  52.   end;
  53.  
  54. procedure TForm1.SenderMouseDown(Sender: TObject; Button: TMouseButton;
  55.                                       Shift: TShiftState; X,Y: Integer);
  56. begin
  57.   case Button of
  58.     mbLeft: TRichMemo(Sender).Lines.Add('Sender Left');
  59.     mbRight: TRichMemo(Sender).Lines.Add('Sender Right');
  60.     mbMiddle: TRichMemo(Sender).Lines.Add('Sender Middle');
  61.     mbExtra1: TRichMemo(Sender).Lines.Add('Sender Extra1');
  62.     mbExtra2: TRichMemo(Sender).Lines.Add('Sender Extra2');
  63.   end;
  64. end;
  65.  
  66. end. // End Form1
  67.  

I installed Lazarus 3.0
I started a new project.
I wrote the code.

It fired on 1 thru 3.
It did nothing on 4 & 5.

However, after installing Lazarus 3, and before I started the new project, all buttons were responding. After I created the new project, and went back to the original project, only 1 thru 3 would fire.

Rick
« Last Edit: January 29, 2024, 02:20:30 pm by RW1962 »

rvk

  • Hero Member
  • *****
  • Posts: 6953
Re: OnMouseDown event
« Reply #27 on: January 29, 2024, 02:29:38 pm »
I installed Lazarus 3.0
I started a new project.
I wrote the code.
I take it that the TForm1.RichMemo1MouseUp was removed because it isn't even in your form declaration.

However, after installing Lazarus 3, and before I started the new project, all buttons were responding. After I created the new project, and went back to the original project, only 1 thru 3 would fire.
Now I'm, confused... AFTER installing Lazarus 3, it worked? Before you started a new project?
How would you know? (did you mean BEFORE ?? With an older program made with pre Lazarus 3.0?)

My question was... does the button 1 thru 3 fire for the Form itself?
If it does, and it doesn't fire for button 4 and 5, then there is something in Lazarus itself preventing 4 and 5.
TRichMemo itself doesn't do anything with buttons. That's handled by Lazarus (and shows that 4 and 5 ALSO don't work for the form or any other component).

If it worked before Lazarus 3 and not after... then I don't know why it's working for me on Laz 3.0 (and in trunk).

RW1962

  • New Member
  • *
  • Posts: 41
Re: OnMouseDown event
« Reply #28 on: January 29, 2024, 04:45:07 pm »
Quote
I take it that the TForm1.RichMemo1MouseUp was removed
You wanted to use OnMemoDown.
Quote
AFTER installing Lazarus 3, it worked? How would you know?
Because it autoloaded my project, and I hit the 4 & 5 buttons.
Quote
... does the button 1 thru 3 fire for the Form itself?
Yes, 1 thru 3 fire, but 4&5 do not.
Quote
I don't know why it's working for me on Laz 3.0
Maybe it is because my projects are Win32 projects.

I have been trying to launch another project that is Win32, and it halts with this message: "Error: Illegal parameter: -Twin32"

By snooping around it gave another message: "FPC.cfg cannot be found"

This why I always avoid updrading to the latest and greatest. I this case, my win32 had quit firing 4 & 5. So I upgraded to see if version3 was doing it or not.

And no, to your former comment, I don't think that this a RichMemo issue. RichMemo is simply where it is happening. I originally thought that it was either Windows or Lazarus.

rvk

  • Hero Member
  • *****
  • Posts: 6953
Re: OnMouseDown event
« Reply #29 on: January 29, 2024, 05:24:01 pm »
Quote
I don't know why it's working for me on Laz 3.0
Maybe it is because my projects are Win32 projects.
I just installed Lazarus 3.0 (rev lazarus_3_0) FPC 3.2.2 i386-win32-win32/win64
(latest Lazarus 3.0 32 bit as secondary installation)
And here the 4 and 5 also work just fine.

I have been trying to launch another project that is Win32, and it halts with this message: "Error: Illegal parameter: -Twin32"
That seems a cross-compile error?

By snooping around it gave another message: "FPC.cfg cannot be found"
I guess you need to try installing Lazarus 3.0 32 bit again as secondary install (it shouldn't interfere with current versions as long as you choose secondary installation to a different path and choose install_path\config as config path). After that you can just try the smallest test-project with a TMemo on the form (without the need to install any components).

I've just installed to Q:\laz3.0 (while I also have Q:\laz3 and Q:\dev and Q:\dev64 installed).

Otherwise I'm at a loss as to why this is happening. I can't reproduce it.

Code: Pascal  [Select][+][-]
  1. type
  2.   TForm1 = class(TForm)
  3.     Memo1: TMemo;
  4.     procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
  5.       Shift: TShiftState; X, Y: Integer);
  6.   private
  7.  
  8.   public
  9.  
  10.   end;
  11.  
  12. // [...]
  13.  
  14. procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  15.   Shift: TShiftState; X, Y: Integer);
  16. begin
  17.   case Button of
  18.     mbLeft: Memo1.Lines.Add('form Left');
  19.     mbRight: Memo1.Lines.Add('form Right');
  20.     mbMiddle: Memo1.Lines.Add('form Middle');
  21.     mbExtra1: Memo1.Lines.Add('form Extra1');
  22.     mbExtra2: Memo1.Lines.Add('form Extra2');
  23.   end;
  24. end;

 

TinyPortal © 2005-2018