Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Refreshing toolbars
Message
From
15/07/2003 23:07:17
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00808690
Message ID:
00810525
Views:
22
Hi Glenn, that's nicer according to my programming habits, but still you do need to check whether some text is selected or not.
Sometimes, when a feature is not supported natively and I have to take a long workaround, I'd rather leave it alone so that the code is clearer and more manageable. I think this is going to be one of those cases, I will leave the cut-copy-paste buttons enabled all the time and let the user "imagine" when they can be used; it's not that much ugly.

Thanks anyway,
Javier.

>There may be another way... What if in a textbox/editbox gotfocus/lostfocus event it would call the toolbar.refreshbuttons method? If this behavior were made part of your base class then it would work universally.
>
>Glenn
>
>>Thanks Glenn, I was afraid the the only way to properly refresh cut-copy-paste was through a timer. I was trying to avoid it because I don't like them a lot as you have to be very careful with the code inside (it keeps executing whatever the user is doing, which is a source of conflicts).
>>
>>Regards,
>>Javier.
>>
>>>Hello Javier,
>>>
>>>Well, the issue of updating the Cut/Copy/Paste toolbar is not pretty, What you need to do can be accomplished in the toolbar button class and a timer. At every timer interval call a method in the button to refresh itself. For instance in the Cut/Copy buttons the refresh method may look something like this:
>>>
>>>tbarButton::Refresh
>>>if type('_screen.activeform.name') = 'C' and ;
>>>  inlist(_screen.activeform.activecontrol.baseclass,'Textbox','Editbox')
>>>  this.enabled = .t.
>>>else
>>>  this.enabled = .f.
>>>endif
>>>
>>>
>>>The timer would fire every .5 seconds (500ms) and it's timer event may look like this:
>>>
>>>tbTimer::Timer
>>>local i
>>>with this.parent
>>>for i = 1 to this.parent.controlcount
>>>  if .controls(i).baseclass = 'Button'
>>>    .controls(i).refresh()
>>>  endif
>>>endfor
>>>
>>>
>>>These are just examples and not production code. You can develop your own techniques and methods from these concepts.
>>>
>>>Glenn
>>>
>>>>>Hi,
>>>>>
>>>>>>>
>>>>>I just wanted to know what is the recommended way to refresh a toolbar:
>>>>>- Timer
>>>>>- Inserting code in thisForm.init() and thisForm.destroy() methods.
>>>>>>>
>>>>>
>>>>>It depends...
>>>>>If the same toolbar is servicing multiple forms then I think that probably the best place is in the Form.Activate/Deactivate events.
>>>>>
>>>>>Regards,
>>>>>Viv
>>>>
>>>>You are right, activate and deactivate methods make more sense. The toolbar is servicing the whole application, so it has buttons related to forms and others that relate to miscelaneous things (like save as, send to ..., cut-copy-paste, ...), and these buttons are the ones who change more from enabled to disabled (think of the cut-copy-paste).
>>>>
>>>>Thanks,
>>>>Javier.
Previous
Reply
Map
View

Click here to load this message in the networking platform