1. Brage Mogstad
  2. PowerBuilder
  3. Friday, 28 January 2022 09:47 AM UTC

Hello,
I'm in dire need of help.
A grid dwo has PFC sort service enabled.
As the user expands a grid column, the pfc_sort service triggers and changes sort statement to the column clicked.
The user is not happy.

I've tried to catch the pointer (Cross!) in pbm_dwnmosemove and disable the sortservice while pointer is Cross!
But describe does not report the pointer.

setting = dw1.Describe("employee_no_t.Pointer")

It reports '!' every time, even though its a known pointer type (Cross!). Is this a PB bug?

Anyone got ideas on how to disable sort service when u resize a grid column?

B

pbm_dwnmousemove:

integer li_tab
string ls_objectatpointer, ls_objname, ls_pointer, ls_modify

ls_objectatpointer = GetObjectAtPointer()
li_tab = Pos(ls_objectatpointer, "~t", 1)
ls_objname = Left(ls_objectatpointer, li_tab - 1)

if len(trim(ls_objectatpointer)) > 0 then
   ls_modify = ls_objectatpointer+".Pointer"
   ls_pointer = this.Describe(ls_modify)
end if

 

 


 

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Monday, 31 January 2022 08:00 AM UTC
  2. PowerBuilder
  3. # Permalink

I have added a "CheckForGrid" option in my extension of PFC sort service. If this option is activated and it is a grid datawindow it checks for a click on the left or right area of the object.

 

// pfc_clicked event in n_cst_dwsrv_sort

string ls_colname, ls_units
long ll_tolerance = 20
long ll_i, ll_xpos, ll_x, ll_w


// some simple checks
IF IsNull(adwo_obj) OR NOT IsValid(adwo_obj) THEN Return FAILURE
IF NOT of_GetColumnHeader() THEN Return NO_ACTION
If adwo_obj.Name = 'datawindow' THEN Return NO_ACTION
IF adwo_obj.Band <> "header" THEN Return NO_ACTION


// click near of grid?
IF ib_checkforgrid THEN
	IF idw_requestor.Describe ("DataWindow.Processing") = "1" THEN
		// only for DW with units PBU or pixels
		ls_units = idw_requestor.Describe("DataWindow.Units")
		IF ls_units = "0" OR ls_units = "1" THEN
			// X-Pos
			ll_xpos = ai_xpos
			IF ls_units = "0" THEN ll_xpos = PixelsToUnits (ll_xpos, XPixelsToUnits!)
			
			// Split-Scrollbars and Scrollposition
			ll_i = Long (idw_requestor.Describe("DataWindow.HorizontalScrollSplit"))
			IF ll_xpos > ll_i AND ll_i > 0 THEN
				ll_xpos += Long (idw_requestor.Describe("DataWindow.HorizontalScrollPosition2")) - ll_i - 18
			ELSE
				ll_xpos += Long (idw_requestor.Describe("DataWindow.HorizontalScrollPosition"))
			END IF
			
			// tolerance of position
			IF ls_units = "1" THEN ll_tolerance = UnitsToPixels (ll_tolerance, XUnitsToPixels!)
			
			// Size of clicked object
			ll_x = Long (idw_requestor.Describe (adwo_obj.name + ".x"))
			ll_w = Long (idw_requestor.Describe (adwo_obj.name + ".width"))
	
			// check for click on right or left border
			IF ll_x + ll_tolerance > ll_xpos OR ll_x + ll_w - ll_tolerance < ll_xpos THEN
				return NO_ACTION  // do not sort
			END IF
		END IF
	END IF
END IF

// normal behaviour
return super::Event pfc_clicked (ai_xpos, ai_ypos, al_row, adwo_obj)
Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Friday, 28 January 2022 15:05 PM UTC
  2. PowerBuilder
  3. # 1

I looked into this very issue over ten years ago.

The problem is due primarily because PB changes the mouse cursor when it is NEAR a vertical grid line in addition to when it is directly over a vertical grid line. I forget what the actual threshold is, but I seem to recall the cursor changes when its position is within three or four pixels of the grid line. When PB changes the cursor's appearance, the user believes they can successfully click/drag and resize the column.

Unfortunately, the logic in GetObjectAtPointer does not work the same way. When the cursor is directly over a vertical grid line, "datawindow" is returned from GetObjectAtPointer. If the mouse is not directly over the vertical grid line, the name of the header column text object on either side of the grid line is returned and the PFC Sort service sorts the rows.

I really wish this discordant behavior was corrected.

At the time I was investigating this issue, I know I had a solution for it, but the powers that be did not want to implement it and the fix fell by the wayside. I think my solution was to add code to the DW's MouseMove event to check the Processing property to see if a possible grid (=1) was being viewed, and if moveable columns was enabled, and if GetObjectAtPointer did not return "datawindow", then explicitly set the cursor to Arrow!, eliminating the misleading visual cue to the user.

I'll see if I can recreate the fix this weekend and verify it works as intended.

John

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 28 January 2022 14:02 PM UTC
  2. PowerBuilder
  3. # 2

Okay, 

I've dowloaded the latest version of pfc 2021 and created a really simple application with a single window and an external dw.

You don't have to do anything at all to avoid the problem your customer is having. So my guess is that either your user has "shaky" hands, or that your PFC version might be very old or adapted in the wrong way.

Please see the attached ZIP file.

regards.

MiguelL

 

Attachments (1)
Comment
  1. Brage Mogstad
  2. Friday, 28 January 2022 19:24 PM UTC
Yes, this example worked out of the box.
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 28 January 2022 19:28 PM UTC
So .... there' s some additional code in your version of the PFC that interferes?
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 28 January 2022 12:32 PM UTC
  2. PowerBuilder
  3. # 3

Hi Brage,

The sort functionality in PFC is a quite deeply nested process. I seem to remember that I had this very same problem once and I'm trying to figure out what I did exactly to stop this from happening. The way you're trying to approach the problem in the mousemove event is definitely not the right procedure. Your describe would return the pointer of the text object, if you'd have one assigned to it in the datawindow. The "cross showing" though, is at another level which I think we can't easily detect.

I seem to remember that what I did, was detect if the clicked was "very near" to the left- or rightmargin of the field and then not run the pfc_clicked of the inv_sort. But ..... still looking for it.

I'll let you know what I find.

Then another thing: Are you sure your customer doesn't have "shaky hands" and when he/she clicks, the cross cursor wasn't there? Can you reproduce the case yourself?

regards,

miguelL

Comment
  1. Miguel Leeuwe
  2. Friday, 28 January 2022 12:40 PM UTC
Meanwhile as a test: See what happens if you override the clicked event of the u_dw and do nothing. Does it still sort? (Saying this because there's this pfc_postLButtonUp() event).

Which version of the pfcs are you using and which version of PB?
  1. Helpful
  1. Arnd Schmidt
  2. Friday, 28 January 2022 13:23 PM UTC
I did that changes in the pfc_clicked () Event of the pfc_n_cst_dwsrv_sort -

To me it seems that this is the owner of the logic how to determine if and how the sort should happen.

Make sure to check the mouse x-position and compare this to a threshold for the distance between the border of the column header text control and the "clicked" X-Position.

For a real PFC change:

Do not forget to do some magic around the used Units in the datawindow: PBUnits vs. Pixels vs.1/1000 innch vs. 1/1000 centimeter.

This looks like an enhancement request for the PFC to me.



regards

Arnd

  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 28 January 2022 13:29 PM UTC
Hi Arnd, yes I seem to remember having done that too, but ... in the u_dw.clicked I also see a call to that event. Since we have pretty heaviliy modified pfE classes, I'm trying to figure out what did the trick for me, as I can't seem to find that comparison of "being close to the border" .

As far as Enhancement requests to the PFCs ... Hmmm, not sure I anyone will take care of those. It's up to us to create any changes and then see if Bruce Armstrong is accepting them.

best regards,

MiguelL
  1. Helpful
There are no comments made yet.
Brage Mogstad Accepted Answer Pending Moderation
  1. Friday, 28 January 2022 14:12 PM UTC
  2. PowerBuilder
  3. # 4

Yes, the sort service is PFC level functionality and really, the best would be to not override at all.
This was easy to replicate btw. If you put the cross just below the sorting column it didtn trigger.
I was thinking briefly about your suggestion today.
C++ and GetCursorInfo might do the trick. 

B

Comment
  1. Brage Mogstad
  2. Friday, 28 January 2022 15:30 PM UTC
Its expanding, not moving. The behaviour of the grid dwo is default. As you want to see more, and see the the cross, click to to drag it (expand it), it sorts the dwo by the column header simoultaniously. Its a drag.
  1. Helpful 1
  1. Brage Mogstad
  2. Friday, 28 January 2022 15:32 PM UTC
Its the 2019 PFC

  1. Helpful 1
  1. Miguel Leeuwe
  2. Friday, 28 January 2022 15:36 PM UTC
Okay, I misunderstood then.

I'll make the same sample app for 2019.

Need some time.

regards
  1. Helpful 1
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 28 January 2022 15:48 PM UTC
  2. PowerBuilder
  3. # 5

here's the same demo for pb 2019 R3 (with PFC 2019).
See attached.

Attachments (1)
Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.