1. John Vanleeuwe
  2. PowerBuilder
  3. Friday, 31 August 2018 14:26 PM UTC

Hi all,

 

Lets say i have an overview screen with hundreds of records, which is being refreshed autmatically. Every 5 seconds the retrieve function is done.

 

Now on the rightclick event of the datawindow , our users can pop a menu with some additionnal functions.

 

What happens is , is when users are rightclicking and the menu pops open, the auto-retrieve function can kick in and change the focus from the current row the user clicked right on , to the first row of the datawindow. I can't change this.

 

In my menu i have functions taking the actual row selected and performing some actions on this record. It happens that the autoretrieve function sets the cursor to the first row , while the user is still looking at our menu to choose from.

 

In the clicked event of the menu , i can code to stop the autoretrieve function. No problem there, but of course i want the autoretrieve function to kick in again after the users has choosen from our menu , or hasn't choosen any menu at all.

 

I thought there would be a destroy/destructor/close event for menu's , but this doesn't exist.

 

How can i fix this iissue without having to start the start of the autoretrieve function after every menu item ?

 

Hope i made some sense here :)

 

 

TIA

John

Accepted Answer
Shenn Sellers Accepted Answer Pending Moderation
  1. Friday, 31 August 2018 17:31 PM UTC
  2. PowerBuilder
  3. # Permalink

How are you doing the refreshing of the data every 5 seconds?  Are you using the Timer() function and event?  If you are using that, then when someone right clicks, you just need to turn the timer off temporarily by calling Timer(0) in the Right Mouse Button event.  Then once the user is done with whatever they can do in there, just turn the Timer back on by calling Timer(5).

Comment
  1. John Vanleeuwe
  2. Friday, 31 August 2018 20:25 PM UTC
Hi Shen,



please read my question again.



my question was exactly how or where to code this function. I can't be putting this function in every menu item.



any other suggestions please ?



John
  1. Helpful
  1. Shenn Sellers
  2. Friday, 31 August 2018 21:03 PM UTC
You put the code in the "rbuttondown" event of the DW. I don't know how many DW's you have, but if you want to be able to stop the auto-retrieval as soon as they right click, that is where you put your code to stop it.



I can't tell you how to code the function, because I don't know how you are making the DW retrieve every 5 seconds. The most common way is using the Timer Event and Function.
  1. Helpful
  1. John Vanleeuwe
  2. Sunday, 2 September 2018 08:08 AM UTC
Hi Shen,



the problem is not where to write the code to STOP the autoupdate function.

the problem is where to write the code to START it again AFTER stopping it when a user has rightclicked to open our menu.



I don't want to code this at the end of every menu item clicked event.



I am looking for an event that's being triggered when the menu closes/destroys….



TIA

John
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 3 September 2018 06:39 AM UTC
  2. PowerBuilder
  3. # 1

What about this:

 

Instead of doing a popmenu directly in the right mouse clicked event, why don't you create a nvo: that nvo will have a constructor and destructor. You can stop the timer in the constructor and re-start the auto refresh in the destructor. You might want to use a user defined event or function to do the actual pop-menu so you can set / pass parameters to it. If you make it auto-instantiate, you'd only have to change your PopMenu() calls to something like ue_popmenu() calls, but I'm not sure if in that case the destructor event will be executed immediately after you finish doing what it's doing.

 

Maybe, to be sure, define a global function f_popmenu(….,...) which then does this:

myUO luo // NOT auto-instantiated

luo = create myUO

luo.event ue_myPopMenu(….,....)

destroy luo

 

HIH,

MiguelL.

Comment
  1. Miguel Leeuwe
  2. Monday, 3 September 2018 07:06 AM UTC
To be honest, now that I'm reading this again: Sehn Sellers' solution of "You put the code in the "rbuttondown" event of the DW" is probably less work: Just restart your auto refresh/update functionality right after your PopMenu() call.

  1. Helpful
  1. John Vanleeuwe
  2. Monday, 3 September 2018 08:06 AM UTC
thanks Miguel. I must have had a brainfreeze , this solution is so simple and clean !



  1. Helpful
  1. Miguel Leeuwe
  2. Monday, 3 September 2018 08:24 AM UTC
hah, yw, me too I eat ice-cream while working :)
  1. Helpful
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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.