Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder Components » View Thread |
Messages 1 to 6 of 6 total |
Interface States |
Mon, Jul 6 2015 1:16 PM | Permanent Link |
Mark Brooks Slikware | Hi
I'm busy building a set of components that will enable faster creation of web apps to talk to our range of REST APIs. So far the task has been pretty straightforward and the results are great. However, I am struggling to get my head around interface states. As an example, I have created a parent component descending from TBasicPanel that instantiates its own TScrollPanel and fills it (at run time) with vertically stacked children, who also descend from TBasicPanel. I think this may be a fairly common configuration for a lot of UIs that deal with pretty lists of stuff. I'd like the children of the scroll panel to subtly change colour when the mouse passes over them and, potentially, change colour more dramatically when they are clicked (essentially becoming "selected"). I had thought that the former functionality would be inherited automatically from TBasicPanel but that does not appear to be the case. I have created an interface state for Normal and Hot but the latter is not automatically triggered. So, I override the UpdateInterfaces method and check for "Over" being true, then set the InterfaceState accordingly. But that doesn't work either. Can anybody help? Furthermore, will the same method be used to handle the "selection"? Thanks Mark |
Tue, Jul 7 2015 4:22 AM | Permanent Link |
Matthew Jones | Mark Brooks wrote:
> However, I am struggling to get my head around interface states. I've wondered about them myself, but being stuck on other projects can't play yet. What you are doing sounds ideal. I'd like to add a "disabled" state myself, but that is just icing. 8-) |
Tue, Jul 7 2015 5:02 AM | Permanent Link |
Mark Brooks Slikware | "Matthew Jones" wrote:
>>I'd like to add a "disabled" state myself, but that is just icing. 8-) Ha! Very true. I think that Tim's mechanism handles all of these (and any others you care to mention) but having trawled through the Interface manager code I must admit that an example would help me a great deal. |
Tue, Jul 7 2015 2:07 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Mark,
<< I had thought that the former functionality would be inherited automatically from TBasicPanel but that does not appear to be the case. I have created an interface state for Normal and Hot but the latter is not automatically triggered. So, I override the UpdateInterfaces method and check for "Over" being true, then set the InterfaceState accordingly. But that doesn't work either. Can anybody help? >> No, TBasicPanel, like many container controls, turns *off* the interface state updating as a performance enhancement: (from WebCtnrs unit) procedure TBasicPanelControl.UpdateInterfaceState; begin { Suppress any interface state changes due to mouse overs, etc. } <<<<<<<< end; If you *want* the interface state to be updated, then simply descend from TControl instead of TBasicPanelControl/TBasicPanel. IOW, just copy the code for TBasicPanelControl to your unit so that you get all of the background, etc. functionality, but change the UpdateInterfaceState method so that the ancestor TControl UpdateInterfaceState method is called and not suppressed: procedure TMyPanelControl.UpdateInterfaceState; begin inherited UpdateInterfaceState; end; << Furthermore, will the same method be used to handle the "selection"? >> You'll have to track the "selection" state as the control is clicked via a Selected Boolean property/member variable for your panel control class, and you would handle it like this: procedure TMyPanelControl.SetSelected(Value: Boolean); begin if (Value <> FSelected) then begin FSelected:=Value; UpdateInterfaceState; end; end; function TMyPanelControl.DoClick: Boolean; begin Selected:=(not Selected); Result:=inherited DoClick; end; procedure TMyPanelControl.UpdateInterfaceState; begin if FSelected then InterfaceState:=SELECTED_STATE_NAME else inherited UpdateInterfaceState; end; Of course, the above has the "selected" state overriding all other states. You may want/need to nuance this a bit more, depending upon your needs for enabled/disabled, etc. states. Tim Young Elevate Software www.elevatesoft.com |
Tue, Jul 7 2015 2:26 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Mark,
One other thing: when you create a clone of the TBasicPanelControl, you'll have created a protected, customizable control. Use the TBasicPanel class code as a guide to how to promote the relevant published properties and set up the interface class name. I used this type of design throughout the component library in order to allow controls to be easily re-skinned via a new interface class name, and to allow for greater customization of which properties are made available in the object inspector. Tim Young Elevate Software www.elevatesoft.com |
Tue, Jul 7 2015 6:21 PM | Permanent Link |
Mark Brooks Slikware | All good Tim. I get it. Will persevere. Thanks.
|
This web page was last updated on Wednesday, April 24, 2024 at 11:07 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |