[Cuis-dev] Update: Alt+Return as a full screen toggle shortcut
Luciano Notarfrancesco
luchiano at gmail.com
Sun Dec 20 20:45:58 PST 2020
I think global shortcuts should be handled first, like it is now; if you
give the opportunity to morphs to handle it first I wouldn’t be able to
override some of the shortcuts I’m using and I would have to change even
more code all over the place to make my shortcuts work.
Also, if the handling is done in the event classes then nothing was solved.
I agree with Juan that we have the option to handle global shortcuts either
in the hand or in the world. Both options make it easy to change the
behaviour, either by introducing a new hand or a new world.
I never needed the full screen thing in Cuis because my X11 window manager
(dwm) does that. In fact, I patched it to do this the way I like it with
win-esc and it works with any window (not only Cuis). I guess some window
managers don’t have a shortcut for full screen? Or are not configurable
with the shortcut you prefer and not easy to patch?
On Mon, 21 Dec 2020 at 9:22 AM, Mauro Rizzi <mrizzi at fi.uba.ar> wrote:
> Hello Ken
>
> You're right, I didn't think about the wasHandled: method before and it's
> a better solution than the one I proposed (assuming the methods
> isFindClassShortcut and isCloseWindowShortcut and Franco's
> isFullScreenShortcut would be moved into handleKeyEvent and the processKey*
> ones would have their return removed).
>
> It would look something like:
>
> vvv============vvv
> KeyBoardEvent>>
>
> sentTo: aMorph localPosition: positionInAMorph
>
> "Dispatch the receiver into anObject"
>
> type == #keystroke ifTrue: [
> aMorph
> processKeystroke: self
> localPosition: positionInAMorph ].
> type == #keyDown ifTrue: [
> aMorph
> processKeyDown: self
> localPosition: positionInAMorph ].
> type == #keyUp ifTrue: [
> aMorph
> processKeyUp: self
> localPosition: positionInAMorph ].
>
> (self wasHandled)
> ifTrue: [^aMorph] "done"
> ifFalse: [<globaldefaultKeyHandler> handleKeyEvent: self]
>
>
> ^^^============^^^
> "Inside globaldefaultKeyHandler, of course if someone thinks this object
> shouldn't exist you could just put it's content on the ifFalse closure.
> Also technically the ifFalse is unnecessary, but it does provide a lot of
> clarity."
> handleKeyEvent: aKeyboardEvent
>
> aKeyboardEvent isFindClassShortcut
> ifTrue: [ ^ BrowserWindow findClass].
> aKeyboardEvent isCloseWindowShortcut
> ifTrue: [ ^ aKeyboardEvent closeCurrentWindowOf: aMorph
> aKeyboardEvent isFullScreenShortcut
> ifTrue: [ ^ Display toggleFullScreen ]
>
> ^^^============^^^
>
> We would have to refactor the current senders of wasHandled: to take into
> account this change.
>
> Thinking on the readability of this method and it might be a bit hard to
> follow the wasHandled method call for someone who is first discovering it,
> since they potentially might not understand how keyboardEvent knows the
> event was handled.
>
> I do approve of the idea of having global keystrokes be in a separate
> object than the standard keyboardEvent, I think it would give clarity to
> the chain of responsibility if it goes into the morph and then into a
> global keystroke handler object.
>
> Thinking about it from an usability standpoint using franco's full screen
> shorcut (alt + enter) we would have to (with both of the proposed
> implementations) make the isFullScreenShortcut check on the keyboardEvent
> inside the target morph to avoid processing the input at the morph level
> and marking it as handled.
>
> What I mean with this is that all morphs would be responsible of knowing
> what inputs they should ignore because the keystrokes that we want to
> capture for system events would also be considered valid inside the morph
> and would be executed.
>
> For example if you press shift enter while writing in a method editor the
> innerTextPane will happily process the input, put the newline into the pane
> and mark the event as handled, following that the keyboardEvent will say
> "ah, well that is done with then, moving on" and the findClass dialogue
> won't pop up, to avoid this you'd have to check whether the current
> keystroke is one of the system ones inside the morph's execution chain.
>
> While I do like your implementation significantly more I think the one I
> recommended earlier gets around this issue. Since it becomes something
> optional, your morph can decide if it wants to override certain keystrokes
> or not but if you don't implement the method shouldOverride (Note: this is
> a bad name for this method) then you go back to the current behaviour.
>
> Basically one option gives the morph the choice to tell you if it wants to
> override or not. The other one gives the morph the responsibility of
> telling you whether you should override or not.
>
> And I still feel keyboardEvent should have a hierarchy of the 3 types of
> keyboard events rather than having a type instance variable.
>
> I just want to clarify I quite enjoy writing walls of text and this is
> intended as constructive brainstorming. I'm sorry if it comes out as
> anything but.
>
> Cheers!
> *Mauro Rizzi*
>
> El dom, 20 dic 2020 a las 20:54, <ken.dickey at whidbey.com> escribió:
>
>> On 2020-12-20 21:25, Mauro Rizzi wrote:
>>
>> ..
>> > shouldOverride := aMorph shouldOverride: self
>>
>> I am suggesting that if the Morph processes the keystroke, it _has_
>> overriden and _does NOT need_ a #shouldOverride method.
>>
>> So
>> vvv============vvv
>> KeyBoardEvent>>
>>
>> sentTo: aMorph localPosition: positionInAMorph
>>
>> "Dispatch the receiver into anObject"
>>
>> type == #keystroke ifTrue: [
>> self isFindClassShortcut
>> ifTrue: [ ^ BrowserWindow findClass].
>> self isCloseWindowShortcut
>> ifTrue: [ ^ self closeCurrentWindowOf: aMorph ].
>> ^ aMorph processKeystroke: self
>> localPosition: positionInAMorph ].
>> type == #keyDown ifTrue: [
>> ^ aMorph
>> processKeyDown: self
>> localPosition: positionInAMorph ].
>> type == #keyUp ifTrue: [
>> ^ aMorph
>> processKeyUp: self
>> localPosition: positionInAMorph ].
>>
>> (self wasHandled)
>> ifTrue: [^aMorph] "done"
>> ifFalse: [<globaldefaultKeyHandler> handleKeyEvent: self]
>>
>>
>> ^^^============^^^
>>
>> Note: I am not an expert here. Just a guess..
>>
>> Prototype is best.
>> -KenD
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20201221/f5528f77/attachment.htm>
More information about the Cuis-dev
mailing list