Thursday, April 15, 2010

Tips & Tricks # 2: Binding 2 or more SSCALs

Yesterday I have shown that an SS Class like SSCAL is not just a mere display to enhance the GUI of your app. It can be used as well to perform other things such as harvesting transactions for the day by using its value via SQL SELECT. Today I will show how to bind, sort of, an SSCAL class to another SSCAL class; on the same form.

Last night, I decided to enhance my Editing Module as users here in PNG are very careless of things. Regardless of several instructions and tools, they stil are very lax in encoding. So I have added another feature, i.e., auto-detecting of several vouchers used on a single asset for a day.

Originally I played with hot-skinning approach. This time however, I wanted to see how SS Classes will work when different colors and themes are combined in a single form; on a real project. And since the new design I have in mind will have a huge empty space on the left, I decided to use two SSCALs; one showing the front cover and the other the inner side. These SSCALs should be binded, sort of, with each other meaning when user clicks on the inner calendar date then the one on the left showing the front will likewise change.
- click on the image to see its real size -
Is it hard? Definitely not! It is actually simple.

Also yesterday I have shown the use of DODEFAULT(), now I will be showing how NODEFAULT favors us. I won't bother showing the codes anymore on how I was able to work on the enhanced editing module. What we will focus is on NODEFAULT and how linking is done on the front cover of the 2nd instance of SSCAL.

Since now we wanted to make it appear that those two SSCAL are binded with each other, we would not want to activate the default action of double-clicking the inner calendar which is showing its front cover (default). So what do we do? Instruct SSCAL "not" to perform that "Default" actions inside the class, i.e., NODEFAULT. On OpgDay DblClick Event, simply issue:

NODEFAULT

And that is it. SSCAL's front cover won't appear anymore. How to link then to the cover of the other SSCAL? Remember these codes from Tips & Trick 1 OpgDay Click Event?

DODEFAULT()
thisform._gridrefresh()

thisform.grid1.AfterRowColChange()


In addition to that, all I need is to add this to the next line:

thisform.sscal2._settings("orange",this.Parent.Parent._value)

So what does that do? I am "injecting" a new value to SSCAL instance # 2, the value coming from SSCAL instance # 1. And that is it!

Now, how about disabling SSCAL's 2nd instance of showing the inner calendar when clicked? Well we can again do the NODEFAULT trick BUT... by trying to prevent unnecessary additional objects inside my classes, I intentionally did not create a shape over the front cover for receiving double-click event. Showing the inner calendar via double-click is distributed to these objects:

a. The front cover image
b. The Calendar Day label
c. The Calendar Day's Shadow label
d. The Clock label
e. The Month label

So, insted of putting NODEFAULT on ALL of abovementioned double-click events, it is simpler to do this trick. Place a transparent-bordeless shape above the calendar and that is it! No amount of double-clicking will work now. Cool?

Enjoy using SSCAL!

No comments:

Post a Comment