Le 8 mars 07 à 15:00 Soir, Emile SCHWARZ a écrit:

>> You also posted some code:
>>
>>   // Toogle the focus ring
>>   Dim theCanvas As Canvas
>>
>>   // Compute if the Focus is set to a Canvas
>>   If Self.Focus IsA Canvas Then
>>     // Cast Canvas Control who have the Focus
>>     theCanvas = Canvas(Self.Focus)
>>
>>     If theCanvas = Me Then
>>       // Ask the Window to clear the focus
>>       ClearFocus
>>     End If
>>
>>   Else
>>     // Ask the Canvas to set the focus
>>     Me.SetFocus
>>
>>   End If
>>
>> You may use a variable of type RectControl to avoid calling
>> Self.Focus more than once, since you know the focus does not change
>> inside your method.
>
> Calling once Self.Focus and a second time RectControl?
> Where is the gain? [the code will be darker than calling Self.Focus  
> with IsA and then Cast it.]

That was not my point.

I was just saying that instead of:

   If Self.Focus IsA Canvas Then
    theCanvas = Canvas(Self.Focus)

you may replace with:

dim r As RectControl

r=Self.Focus
if r IsA Canvas then
theCanvas=Canvas(r)
end if

But that's not so important.

>>>> To clears the Focus from the Canvas, I have to use a Window command
>>>> - ClearFocus - and to set the Focus to the canvas, I have to use a
>>>> Canvas command - Me.SetFocus - ; where the code consistency?.
>>
>> You learnt german, right? (every noun starting with a capital
>> letter)  ;-)
>
> No, we speak French at home and I learn English at school (then  
> music, comics, tourists, computing). The only German I know was by  
> meeting (in shops) German tourists ;)
>
> Also, US people use an upper character at the start of each songs  
> in the music industry - and some french people do the same for  
> french titles!).
>
> And the reason why I was highlighting that is because it is more  
> readable to have an uppercase at the beginning of a new part of a  
> command: 'showwindow' and 'ShowWindow'; 'nilobjectexception' and  
> 'NilObjectException'.
>
> But this is just me and I only ask that in the software ad in its  
> documentation. Everyone (else) is free to code at will using  
> lowercase, UPPERCASE or TitleCase... and even a mix of these ;)

I know all that. I was somehow kidding.

>> It may not be inconsistent. Each class is dealing at its level.
>
> Have a look at the REALbasic 'Preferences', 'Code Editor', the  
> 'Autocomplete apply standard case' CheckBox.
>
> Also, read the Language Reference for REALbasic 1.0 (and some  
> following revisions).
>
> Of course one who comes from java will have the habit to write  
> showWindow (as an example).

When I said "It may not be inconsistent. Each class is dealing at its  
level.", I was referring to the ClearFocus and SetFocus examples.

>> Could you imagine a RectControl with a ClearFocus method to clear the
>> focus of the window? Does not make sense. Maybe adding a
>> RemoveFocusFromMe would make sense, but the concept of removing the
>> focus of ANY control that has it would break.
>
> No, I do not imagine that. I think at RectControl.ClearFocus. No,  
> it will not break if written correctly. [1]
>
>> For setting the focus, using self.SetFocus(MyControl) is a bit odd.
>> Also, from the API, the focus is set from the control (it's it that
>> has the Focus property and, therefore, a way to grab the focus).
>>
>> So I don't see how you would like to see a more consistent way to
>> remove/set the focus.
>
> Very simple, stay with the actual SetFocus and add a ClearFocus  
> like in [1]:
>
> EditField1.SetFocus
> EditField1.ClearFocus
>
> The first set the focus to EditField1 and naturally, the second  
> clears the focus from EditField1. And do not remove the Window  
> Class' ClearFocus because it make sense too (it have it use too).

Why having every rectcontrol a ClearFocus method to remove only the  
focus of itself when the window can handle all that?

Say EditField2 has the focus and you call:
EditField1.ClearFocus

You certainly wrote "EditField1.ClearFocus" in the meaning of  
removing the focus in the window (it's the action you expect). So I  
think it's not consistent.
Removing the focus of one control means either clearing the focus (if  
the control has the focus) or nothing (if another control or no  
control has the focus). So Self.ClearFocus is the correct way, in my  
opinion.

> Don't you use a key to Power On / Power Off your car ? It would be  
> surprising to have one key for the Power On process and a second  
> one to Power Off the engine! (Yes, there is an alternate - but not  
> hallal - method to Power Off the car engine...)

I don't have a car ;-)

> Thank you for reading,

You're welcome.

> Emile

Arnaud

> [1] Get an eye in Window.DropOpject and <Control>.DropObject  
> events: the former is coded 'AcceptFileDrop("text")' and the later:  
> 'Me.AcceptFileDrop("text")'.

In which example?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to