Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.886.mcz ==================== Summary ==================== Name: Morphic-mt.886 Author: mt Time: 16 April 2015, 1:54:44.817 pm UUID: 18559879-ba01-5e4b-a89a-06fc842be3d7 Ancestors: Morphic-mt.885 Fixes position of user dialogs if no position is provided. Ensures to use the actual mouse cursor position. =============== Diff against Morphic-mt.885 =============== Item was changed: ----- Method: UserDialogBoxMorph>>runModalIn:forHand:at: (in category 'running') ----- runModalIn: aWorld forHand: aHand at: aPointOrNil "Ensure that we have a reasonable minimum size" | oldFocus pos offset | (ProvideAnswerNotification signal: self label asString) ifNotNil:[:answer| ^answer]. self openInWorld: aWorld. + pos := aPointOrNil ifNil: [ + "If called after a longer UI operation, be sure to use the current mouse cursor. Hand position is not up-to-date. Do one world cycle does not help if there are currently no mouse events. So, we *have to be* this extreme." + Sensor cursorPoint]. - pos := aPointOrNil ifNil: [aHand position]. offset := aPointOrNil ifNil: [selectedButton fullBounds origin - (selectedButton fullBounds extent // 2 * (-1@1))] ifNotNil: [self fullBounds extent // 2]. self setConstrainedPosition: pos - offset hangOut: false. oldFocus := aHand keyboardFocus. aHand newMouseFocus: self. aHand newKeyboardFocus: self. savedLabel := selectedButton label. [self isInWorld] whileTrue:[aWorld doOneSubCycle]. oldFocus ifNotNil:[aHand keyboardFocus: oldFocus]. ^value! |
On 16.04.2015, at 11:54, [hidden email] wrote: > Marcel Taeumel uploaded a new version of Morphic to project The Trunk: > http://source.squeak.org/trunk/Morphic-mt.886.mcz > > ==================== Summary ==================== > > Name: Morphic-mt.886 > Author: mt > Time: 16 April 2015, 1:54:44.817 pm > UUID: 18559879-ba01-5e4b-a89a-06fc842be3d7 > Ancestors: Morphic-mt.885 > > Fixes position of user dialogs if no position is provided. Ensures to use the actual mouse cursor position. > > =============== Diff against Morphic-mt.885 =============== > > Item was changed: > ----- Method: UserDialogBoxMorph>>runModalIn:forHand:at: (in category 'running') ----- > runModalIn: aWorld forHand: aHand at: aPointOrNil > "Ensure that we have a reasonable minimum size" > | oldFocus pos offset | > (ProvideAnswerNotification signal: self label asString) ifNotNil:[:answer| ^answer]. > self openInWorld: aWorld. > + pos := aPointOrNil ifNil: [ > + "If called after a longer UI operation, be sure to use the current mouse cursor. Hand position is not up-to-date. Do one world cycle does not help if there are currently no mouse events. So, we *have to be* this extreme." > + Sensor cursorPoint]. I am not really happy with the direct access to Sensor here. What about self activeHand position or probably self activeHand lastEvent cursorPoint ? Isn't this info up-to-date? Best -Tobias > - pos := aPointOrNil ifNil: [aHand position]. > offset := aPointOrNil > ifNil: [selectedButton fullBounds origin - (selectedButton fullBounds extent // 2 * (-1@1))] > ifNotNil: [self fullBounds extent // 2]. > self setConstrainedPosition: pos - offset hangOut: false. > oldFocus := aHand keyboardFocus. > aHand newMouseFocus: self. > aHand newKeyboardFocus: self. > savedLabel := selectedButton label. > [self isInWorld] whileTrue:[aWorld doOneSubCycle]. > oldFocus ifNotNil:[aHand keyboardFocus: oldFocus]. > ^value! > > |
On 16.04.2015, at 06:16, Tobias Pape <[hidden email]> wrote:
> > I am not really happy with the direct access to Sensor here. +1 Never use Sensor in Morphic code. - Bert - smime.p7s (5K) Download Attachment |
In reply to this post by Tobias Pape
On Thu, Apr 16, 2015 at 3:16 PM, Tobias Pape <[hidden email]> wrote:
The info is not up to date, the mouse position is where the mouse down / up happened that started the update process. Karl
|
In reply to this post by Bert Freudenberg
Why? It just fetches the mouse position directly through the VM because we cannot rely of regular event processing in this case. I consider "Sensor cursorPoint" quite valuable for these situations as we seem have no alternative for this case...
Best, Marcel |
On 16.04.2015, at 12:39, Marcel Taeumel <[hidden email]> wrote:
> > Why? It just fetches the mouse position directly through the VM because we > cannot rely of regular event processing in this case. I consider "Sensor > cursorPoint" quite valuable for these situations as we seem have no > alternative for this case... Has nobody ever mention that global variables are bad? ;) Anyway, it violates the abstraction of Morphic by reaching down to the underlying low-level interface. For example, it breaks if you put the world into a window, or into an OpenGL texture, etc. For the same reason, you should not access Display directly. - Bert - smime.p7s (5K) Download Attachment |
In reply to this post by marcel.taeumel (old)
On 16-04-2015, at 12:39 PM, Marcel Taeumel <[hidden email]> wrote: > Why? It just fetches the mouse position directly through the VM because we > cannot rely of regular event processing in this case. Ah but it carefully and with malice throws away all the other events in the event queue. That can cause much pain. It isn’t actually running any vm prim to read the mouse position, not like in the old days when mice were real mice... tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Fractured Idiom:- L'ETAT, C'EST MOO - I'm boss around here |
Well, the problem is that there are no other (mouse) events in the queue at that moment. That is why #doOneCycle is not sufficient there. Not sure how many events get cached in the Squeak UI process is busy...
Best, Marcel |
On 17.04.2015, at 07:44, Marcel Taeumel <[hidden email]> wrote:
> > Well, the problem is that there are no other (mouse) events in the queue at > that moment. That is why #doOneCycle is not sufficient there. Not sure how > many events get cached in the Squeak UI process is busy... Using the active hand's position is the Right Thing. What problems do you see with that? - Bert - smime.p7s (5K) Download Attachment |
ActiveHands position here is last mouseDown/ mouseUp starting the update process. If you start update from menu in upper left corner, the mouse position will be there. The information box will pop up in the upper left corner, regardless of where the mouse cursor is on screen. Karl On Sat, Apr 18, 2015 at 12:20 AM, Bert Freudenberg <[hidden email]> wrote: On 17.04.2015, at 07:44, Marcel Taeumel <[hidden email]> wrote: |
That's one reason we moved the progress bars to the center of the world. - Bert -
smime.p7s (5K) Download Attachment |
On Sat, Apr 18, 2015 at 2:00 AM, Bert Freudenberg <[hidden email]> wrote:
Then it is probably the best solution here, too. If direct Sensor access breaks other code, just doing a fallback to a predictable default seem better than popping it up the dialog box at a unexpected place Karl
|
Free forum by Nabble | Edit this page |