Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Nov 18, 2019 1:53 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: How to block mouse/keyboard inputs during a calculation?
PostPosted: Sat Mar 17, 2012 9:30 am 
Offline

Joined: Mon Jan 23, 2012 10:12 am
Posts: 73
My written software does some time consuming calculations.
During the calculation I am doing "App.doevents" to prevent the windows warning that the software is not responding.

But what I still want to prevent is reacting to keyboard inputs and to mouse clicks while in the calculation loop. Windows should react as normal, I only want to prevent any response to input of my software.

Is the only way doing this to set an I am busy marker and check in every mouse or keyboard control event for its existance to do "return true" ?

Any help or some tipps, or do I have to rewrite all my controls ?


Schnitzelbrain

_________________
Using RealBasic Personal WIN 2011v3


Top
 Profile  
Reply with quote  
 Post subject: Re: How to block mouse/keyboard inputs during a calculation?
PostPosted: Sat Mar 17, 2012 10:58 am 
Offline

Joined: Mon May 30, 2011 12:56 am
Posts: 702
Disable the controls while you work.


Top
 Profile  
Reply with quote  
 Post subject: Re: How to block mouse/keyboard inputs during a calculation?
PostPosted: Sat Mar 17, 2012 11:12 am 
Offline

Joined: Mon Jan 23, 2012 10:12 am
Posts: 73
kermit wrote:
Disable the controls while you work.


Thats what I feared, so i have to rewrite my code for 50 controls :(

Schnitzelbrain

_________________
Using RealBasic Personal WIN 2011v3


Top
 Profile  
Reply with quote  
 Post subject: Re: How to block mouse/keyboard inputs during a calculation?
PostPosted: Sat Mar 17, 2012 11:28 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
If you have 50 controls then I suggest you refactor your code..... think about control arrays for example, espeically if the controls are mostly of the same type

When you calculations start.. set a global variable (example BUSY=TRUE)

On each control put "IF BUSY THEN <return> <exit sub>" etc.

When calculations complete.... BUSY=FALSE



Not sure... but you MIGHT be able to over-ride mouse/keyboard at the WINDOW level (return true in MOUSEDOWN and KEYDOWN)
and then none of the controls on that window will ever see the event.

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: How to block mouse/keyboard inputs during a calculation?
PostPosted: Sat Mar 17, 2012 11:39 am 
Offline

Joined: Mon May 30, 2011 12:56 am
Posts: 702
You can iterate through all the controls on a window and disable them that way

dim x as Integer
for x = 0 to self.ControlCount -1
try
rectcontrol(self.control(x)).enabled = false
catch
end try
next


Top
 Profile  
Reply with quote  
 Post subject: Re: How to block mouse/keyboard inputs during a calculation?
PostPosted: Sat Mar 17, 2012 11:48 am 
Offline

Joined: Mon Jan 23, 2012 10:12 am
Posts: 73
DaveS wrote:
If you have 50 controls then I suggest you refactor your code..... think about control arrays for example, espeically if the controls are mostly of the same type

When you calculations start.. set a global variable (example BUSY=TRUE)

On each control put "IF BUSY THEN <return> <exit sub>" etc.

When calculations complete.... BUSY=FALSE



Not sure... but you MIGHT be able to over-ride mouse/keyboard at the WINDOW level (return true in MOUSEDOWN and KEYDOWN)
and then none of the controls on that window will ever see the event.



Control arrays is a good suggestion didn't look into that till now.
I have canvas, menus, buttons, bevelbuttons, textfields, several windows, listboxes, tabpanels and so on. all reacting somehow to mouse clicks and keyboard shortcuts
So the array would work with the buttons when I am correct. I take a look into the example section of RB.

I tried already the window level but it only works as long as I am in the window itself, as soon as I enter a object, like the listbox then it reacts again.


@kermit
Also a good one. I have to make a matrix then because the controls are constanly changing between enabled and disabled during the normal software usage. So I have to cover what object is enabled disabled before starting to disable all. i.e. the Print button is only enabled when certain fields hold data.
Also disabling a textfield makes it not reacting to the output of the inbetween calculating output.

Thanks for all the advices so far.

Schnitzelbrain

_________________
Using RealBasic Personal WIN 2011v3


Top
 Profile  
Reply with quote  
 Post subject: Re: How to block mouse/keyboard inputs during a calculation?
PostPosted: Sat Mar 17, 2012 12:29 pm 
Offline

Joined: Mon Jan 23, 2012 10:12 am
Posts: 73
@DaveS
So a question to the arrays.

When i have a button array, the action event gets an index and i have to find the final action of the button by checking the index given. Lets say with a case statement.

Is that correct so far?

Can I transfer all my already made buttons into an array?
What happens then with the already written action code ?

_________________
Using RealBasic Personal WIN 2011v3


Top
 Profile  
Reply with quote  
 Post subject: Re: How to block mouse/keyboard inputs during a calculation?
PostPosted: Sat Mar 17, 2012 1:25 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
You could subclass all your controls and put code in the subclass to handle MouseDown during the calculation. Then set the Super of each control on the window to one of your subclasses.

Also, nobody has mentioned this yet, but put your calculation into a thread. Do not use DoEvents for this purpose.


Top
 Profile  
Reply with quote  
 Post subject: Re: How to block mouse/keyboard inputs during a calculation?
PostPosted: Sat Mar 17, 2012 2:01 pm 
Offline

Joined: Mon Jan 23, 2012 10:12 am
Posts: 73
timhare wrote:
You could subclass all your controls and put code in the subclass to handle MouseDown during the calculation. Then set the Super of each control on the window to one of your subclasses.

Also, nobody has mentioned this yet, but put your calculation into a thread. Do not use DoEvents for this purpose.


Great tipp with the subclass, so all my control names stay the same and my code can stay as is. :)

Threading I heard about that one :oops: Any suggestion where i find good explenation how to do threaded programming in RB.

I think my spagetticode type of programming giving a lot of flaws. Well back to the books. At least i learned how to use the events :roll:


Schnitzelbrain

_________________
Using RealBasic Personal WIN 2011v3


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group