I'm a PC guy. I probably haven't spent more than 3 hours in my life working on a Mac, so I find the one mouse button thing very strange. No context menus? Shame! I mentioned this in a post yesterday and got a nice reply from Jake (no url). Thought I'd post his reply.
So, the question - Why does a Mac only have one mouse button?
“First, I have to say that the right-click-to-get-a-context-menu convention that has materialized since Windows 98-ish is useful.
That said, the way to get different click behaviors on the Mac has always (geez, since 1985 or so...) been to "chord" with the left hand. On a Mac keyboard, the shift, control, option, and command keys are in a cluster in the lower corner of the keyboard. You shift-click or shift-command-click or option-command-click, etc. Very easy to get used to making combinations of keys with your left while clicking with your right.
And yes, you can chord in Windows, but from keyboard to keyboard the layout of which keys go where (including that new "Windows" key) varies so much that it can be tricky. And also, during the thirteen years between chording the right-click-convention, I was making a bunch of money with Photoshop, MacDraw, and Pagemaker, rarely having to use the menus to do anything...
So, these days, in Win-land, you CAN drink coffee with one hand and do TWO different useful things with your right, but for the times you're not drinking, the Mac-ists can play chords with the left hand and melody with the right. Pretty cool stuff.”
Thank you, Lutz Roeder! After two (frustrating) days I have finally solved my problem by looking at the System.Web source code using Reflector.
Here's the scenario - I have a DropDownList that gets created in a custom control's CreateChildControls method. Lets call the custom control ParentControl and the dropdown MyDDL. I tried to access MyDDL's SelectedIndex from ParentControl.CreateChildControls, but the selectedIndex was always wrong.
That I did not understand at all. When MyDDL is added to ParentControl's controls collection, the dropdown list should play catch-up. Since ParentControl's state is “Loaded“, MyDDL should load its viewstate, load its postback data and set its SelectedIndex, then call its own OnLoad method (don't know what I'm talking about? Check out this post).
The problem - LoadPostData is not part of the control's catching-up process.
MyDDL.LoadPostData is called by the web page itself. The web page has a method called ProcessPostData. This method steps through the postback data and tries to find the related controls by calling FindControl for each postback value. FindControl in turn calls EnsureChildControls. See what I'm getting at? EnsureChildControls then calls CreateChildControls (where we are trying to get MyDDL's SelectedIndex).
The important thing to note is that at this point LoadPostData has not been called on MyDDL yet! So the SelectedIndex has not been set yet.
Congrats to anyone who actually followed this. Usually I am not very good at explaining things :)
I learnt a new c# keyword today - continue.
In this code, while i > 10, ProcessTwo() will never be called.
for (int i = 0; i < 50; i++)
{
ProcessOne();
if (i > 10)
continue;
ProcessTwo();
}
Here in South Africa the MAC market is very small (except under the graphic designers). My girlfriend is a graphic designer. I am still stumped by the single mouse button thing. Why oh why?
So I had to smile when I read about Scott Hanselman updating an old Mac's firmware.
This is great. I haven't got round to reading a .NET 2 book or tutorial. So I know that master pages and generics and all that exists, but I don't know how to use them.
Luckily the DotNetTemplar pointed out the ASP.NET 2 QuickStarts(beta). I learnt .NET 1.0 through the original QuickStarts. It sounds like a logical place to start learning about the new stuff.