Alaska Software Inc. - Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1)
Username: Password:
AuthorTopic: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1)
Itai Ben-ArtziRight-Click prevents posting events in XbpBrowse() - Test30.zip (0/1)
on Sun, 27 Dec 2020 23:53:50 -0800
It seems the rbDown conflicts with or stops posting ItamMarked event.
What is missing?
Attached is a short demonstration of the issue.

Thanks, and Happy New Year!
-Itai
Andreas Gehrs-Pahl
Re: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1)
on Mon, 28 Dec 2020 16:28:11 -0500
Itai,

>It seems the rbDown conflicts with or stops posting ItamMarked event.

You seem to believe that the xbeBRW_ItemMarked event moves or updates the 
highlight in a browse to show/highlight the selected cell (or row). But that 
is NOT the case, as I tried to explain in some of the earlier threads.

The xbeBRW_ItemMarked event is created AFTER the cursor has been moved to 
the newly selected cell (or row) and AFTER the highlight has been drawn. It 
simply executes the oBrowse:ItemMarked method -- which doesn't do anything 
unless you overloaded the method in a derived class -- and it evaluates the 
oBrowse:ItemMarked callback slot, which means it executes a codeblock that 
was assigned to the "ItemMarked" property (or iVar/Instance Variable) of the 
oBrowse.

Therefore posting an xbeBRW_ItemMarked event has no effect whatsoever in 
your program!

The routine that moves the cursor and highlights the current cell (or row) 
is actually the oBrowse:ItemLbDown method. So, to move the cursor to a 
specific cell (or row) and highlight it, you need to call that method.

Basically, you should make the following changes in your code to make it do 
what you apparently want:

oBrw:GetColumn(1):DataArea:LbDown := {|aPos, uNIL, oSelf| XOR_Pick(oBrw, ; 
aData, aPos, oSelf, .f.)}

oBrw:GetColumn(1):DataArea:RbDown := {|aPos, uNIL, oSelf| XOR_Pick(oBrw, ; 
aData, aPos, oSelf, .t.)}

[...]

Procedure XOR_Pick(oBrowse, aArray, aPosition, oCell, lMove)
LOCAL nRow := oCell:CellFromPos(aPosition)
   if lMove
      oBrowse:ItemLbDown(nRow, 1)       Move cursor to the new cell
   endif
   oBrowse:ForceStable()                Update oBrowse:Cargo value
   aArray[oBrowse:Cargo, 1] := .not. aArray[oBrowse:Cargo, 1]
   oBrowse:RefreshAll()                 Display updated data
return

Some other remarks:
* There is no need to use the "@" (by reference operator) for the oBrw and 
  aData values in the codeblocks, as you replace neither the browse table 
  nor the data array in your XOR_Pick() routine.
* You should always use "oSelf" (not "Self") as variable name in your 
  codeblocks, as "Self" has a special meaning in Xbase++.

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC
Andreas Gehrs-Pahl
Re: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1)
on Mon, 28 Dec 2020 16:45:58 -0500
Itai,

Instead of the following line:

   oBrowse:ItemLbDown(nRow, 1)       Move cursor to the new cell

You should actually use this line:

   oBrowse:ItemLbDown(nRow, oBrowse:GetColumn(1))

Even though both lines will work in your particular case (because you only 
deal with the first column), this is just by accident!

Sorry for the confusion.

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC
Itai Ben-ArtziRe: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1)
on Mon, 28 Dec 2020 15:07:37 -0800
Andreas,
The lbDown is working fine.  It is the rbDown that fails.
Try the sample.
-Itai
Jose Antonio Diego KerejeRe: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1)
on Tue, 29 Dec 2020 11:48:02 +0100
Hi,

I don't know if I have understood correctly. I have modified your code to 
work properly.

Regards. Diego


Test30.PRG
Jose Antonio Diego KerejeRe: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1)
on Tue, 29 Dec 2020 17:18:35 +0100
Hi,

Now I think I have understood your problem. Try this new code.

Regards. Diego


Test30.PRG
Itai Ben-ArtziRe: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1) - Test30A.PRG (0/1)
on Tue, 29 Dec 2020 14:56:33 -0800
Thank you, Diego!
The navigation looks a better approach than PostAppEvent (why I didn't
think about it), but still cause a crash if ItemMarked callback is set
(see attached revised sample).

Regardless, seems there is a conflict between oBrowse:itemRbDown and
oBrowse:GetColumn(x):dataArea:rbDown (should be either resolved or
documented).

Nevertheless, your solution is a step forward, again, many thanks!
-Itai
Itai Ben-ArtziRe: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1) - Test30A.PRG (1/1)
on Tue, 29 Dec 2020 14:56:34 -0800
Itai Ben-ArtziRe: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1) - Test30A.PRG (0/1)
on Tue, 29 Dec 2020 15:01:55 -0800
Thank you, Diego!
The navigation looks a better approach than PostAppEvent (why I didn't
think about it), but still cause a crash if ItemMarked callback is set
(see attached revised sample).

Regardless, seems there is a conflict between oBrowse:itemRbDown and
oBrowse:GetColumn(x):dataArea:rbDown (should be either resolved or
documented).

Nevertheless, your solution is a step forward, again, many thanks.
Itai Ben-ArtziRe: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1) - Test30A.PRG (1/1) - Test30A.PRG (1/1)
on Tue, 29 Dec 2020 15:01:57 -0800
Jose Antonio Diego KerejeRe: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1) - Test30A.PRG (1/1) - Test30A.PRG (1/1)
on Wed, 30 Dec 2020 01:04:21 +0100
Hi,

I think you're getting too complicated. Do not use itemMarked callback (for 
example, you will have interference with the keyboard).
I have made a few changes to your code to make it work properly (although I 
don't understand the implemented logic).

Regards. Diego


Test30.PRG
Jose Antonio Diego KerejeRe: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1) - Test30A.PRG (1/1) - Test30A.PRG (1/1)
on Wed, 30 Dec 2020 01:17:44 +0100
This is how the contextual menu that you can see in the screenshot is 
implemented.

Regards. Diego


Menu.png
Andreas Gehrs-Pahl
Re: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1)
on Tue, 29 Dec 2020 15:03:52 -0500
Itai,

>The lbDown is working fine. It is the rbDown that fails.
>Try the sample.

Have you made the changes that I posted? Of course I tried your example, 
and I fixed it for you. Making those changes to your original code will fix 
the issue, just as Diego's second program does, but without introducing a 
derived class.

Just in case you don't believe me and to save you a couple of minutes, 
attached is the modified program.

Please re-read my post and try to understand it. If you have questions about 
it, please ask, and I will try to explain it better. Fixing the same or 
similar issues for you over and over isn't really as efficient as making 
sure that you understand the problem, so you can solve it yourself in the 
future.

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC

Test30.prg
Itai Ben-ArtziRe: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1)
on Tue, 29 Dec 2020 20:18:06 -0800
Thank you, Andreas!
All of the methods, (i) my first :Up or :Down, (ii) my second
(PostEvent), (iii) Diego's (Navigate), and (iv) yours (convert rb to
lb), are working well, but only without any ItemMarked callback.  All
four solutions fail to work with ItemMarked callback.  Obviously, I
shall either force a user to click an item before any right-click, or
remove the ItemMarked and set a customized popup menu [for each row]
in a different way than via the ItamMarked.

Again, many thanks to you and Diego for showing me a better way to
perform this task.
-Itai
Andreas Gehrs-Pahl
Re: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1)
on Wed, 30 Dec 2020 18:04:35 -0500
Itai,

>All four solutions fail to work with ItemMarked callback.

I don't understand. You didn't have any ItemMarked callback slot until you 
last and final post in this thread. All other programs in this thread have 
no ItemMarked callback slot at all.

The program that actually had a codeblock in the ItemMarked callback slot 
executed a complex program -- "SetSysMenu()" -- that created and destroyed 
Menus and even contained Sleep()s. As the ItemMarked method is executed 
asynchronously every time after any cell is selected (with the mouse or 
keyboard), it should only contain code that is fast and has a low impact.

In some previous threads we already established that creating menus (or 
other complex tasks) within the ItemMarked method or callback slot is a bad 
idea. If you want to create or update a menu, do it in the RbDown() method 
or callback slot, as that is the (only) place it is needed.

There is no conflict with having a ItemMarked callback slot and any of the 
programs, as long as you keep it short and quick. Just add the following 
line to either mine or Diego's program, and you will see that there is no 
issue, whatsoever:

oBrw:ItemMarked := {|aRowCol, uNIL2, oSelf| ;
     oDlg:SetTitle('Item Marked at: ' + Var2Char(aRowCol))}

Just do NOT put any slow or complex code -- and especially no Sleep() -- 
into asynchronously called codeblocks, like the ItemMarked callback slot. 
Then there should be no problem at all.

BTW, when running your code, and you right-click on several different cells 
in quick succession, the program ends without XppFatal.log (or any other 
log), because of an OS Error of "0xC000041D" or "-1073740771", which is: 
STATUS_FATAL_USER_CALLBACK_EXCEPTION.

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC
Itai Ben-ArtziRe: Right-Click prevents posting events in XbpBrowse() - Test30.zip (0/1)
on Wed, 30 Dec 2020 16:05:00 -0800
Yes, Andreas.  I've realized that destroying and rebuilding a menu is
not suitable for the ItemMarked callback.  I should get rid of this
practice.
Many thanks for your replies.
-Itai