Troubles with MouseLeft2 in Browse event New selection

Clarion 11.1: Catch double-click on browse/list with CHT HandyMarkerBrowse

I have a browse with CHT HandyMarkerBrowse added.

Because Gus is no longer available, I need to find another solution.

I had to replace the original ?Change button with my own PowerTemplate button. When I removed the original ?Change button, double-click no longer called the update/change logic. At first the original button was only hidden, but now it is removed.

I want to catch a double-click on the browse and call my own procedure.

In NewSelection I tried:

db.debugout('List:6')
db.debugout(KEYCODE(),'KEYCODE()')

IF FIELD() = ?List:6
  IF KEYCODE() = MouseLeft2
    MESSAGE('Double click detected')
  END
END

But KEYCODE() returns 1 for both single-click and double-click.

If I scroll up/down I get 38 and 40, so KEYCODE() works for keyboard navigation.

Question:
Is KEYCODE() in EVENT:NewSelection simply the wrong way to catch a double-click on a browse/list?

What is the correct embed point/code to catch MouseLeft2 on ?List:6 and call my own change procedure?

Wrong event to process keycodes.

Hi Edvard,
Please try:
in Control Events → ?List:6 ->Alertkey-> IF …
kind regards,
Pierre-Jean

I think New Selection is the right event.

If you look at the code generated for a Legacy Browse in the Brw1::NewSelection routine it checks for MouseLeft2 and presses the Change button. I’ll post the code tomorrow.

You will first get the Mouse Left Single Click, then the Double-Click will be a 2nd event. Are you clicking fast enough?

Possibly something is getting to it first. An Alert Event would preempt.

You should be in the Event Embeds for the List control i.e. OF ?List 6. So there should be no need for your IF FIELD() = ?List:6 THEN because its only for that 1 control.

Event:AlertKey is the place, says docs: This is the event on which you perform the action the user has requested by pressing the alert key.

ABC classes (abbrowse.clw) does this in TakeKey method, which is called on Event:AlertKey.

That is correct, its not New Selection in the Legacy template generated code:

    CASE FIELD()
    OF ?Browse:DimCodes
      CASE EVENT()
      OF EVENT:NewSelection 
           DO BRW1::NewSelection
      OF EVENT:AlertKey
           DO BRW1::AlertKey

BRW1::AlertKey ROUTINE
!|
!| This routine processes any KEYCODEs experienced by the BrowseBox.
!| This routine includes handling for double-click. Actually, this handling is in the form of
!| EMBEDs, which are filled by child-control templates.
  IF BRW1::RecordCount
    CASE KEYCODE()       ! What keycode was hit
...
    OF MouseLeft2        ! Double-Click on List.
      IF LocalRequest = SelectRecord
        POST(EVENT:Accepted,?Select:2)
        EXIT
      END
      POST(EVENT:Accepted,?Change:3)
      DO BRW1::FillBuffer

    OF InsertKey
      POST(EVENT:Accepted,?Insert:3)
    OF DeleteKey
      POST(EVENT:Accepted,?Delete:3)
   ...

I’m sure I’ve coded it fine in New Selection, but the Left2 key cannot be Alerted for it to work because the Alert event will prevent NewSelection. I would have done that in a hand coded List i.e. that not use a Browse template.

using of the embed Alertkey was the solution.
THANKS!
One funny detail was, that debuger still don’t make any difference on single click and double click.
It simly cannot show hexadecimals correctly.

Best regards

Edvard Korsbæk