|
From: Kevin W. <kw...@co...> - 2010-03-10 15:44:10
|
I've run across a strange bug in my Tk-Cocoa macsheet package: the sheet window behaves differently whether it's called from a menu item or a button command/keyboard shortcut. If the sheet is called from a button or keyboard shortcut (which is how I tested the package), the window withdraws, suddenly appears as a sheet, then slides back up smoothly when it's dismissed (as sheets customarily do). This behavior isn't perfect, but it was the best I could come up given the difficulties I had in integrating the sheet animation (which is controlled by Cocoa at a low level) and the window geometry (which is controlled by Tk). In testing a new application and calling a sheet dialog from the menu, I noticed something different: the sheet window actually slid down as it's supposed to. The geometry was off (it attached to the very top of the window decoration), but the sliding effect was correct (and unexpected). Here are the specific differences. Let's say I have a parent window $parent and a sheet window $sheet. If I set the window geometry %Y of $sheet thus: [winfo rooty $parent] then the sheet draws correctly when called from the menu and 22 pixels too low when called from the button or keyboard shortcut. If I set the window geometry %Y of $sheet thus: [winfo y $parent] then the sheet draws with correct geometry (and no animation) when called from the toolbar and 22 pixels too high (i.e. the very top of the window) when called from the menu. I'm trying to figure out what's going on here. I wonder if invoking the sheet command from the menu causes more events to happen at the lower Cocoa level (i.e. the sliding starts correctly) before Tk's window geometry take control. I don't think there should be any difference between a command called from a menu or a button, but because the sheet package goes deeper into Cocoa windowing operations than typical Tk packages do, perhaps things aren't behaving quite as expected. I'm also not sure how to work around these issues. The most brute-force way to do this would be to set up different procedures for drawing the window from a menu command vs. a button, and documenting this in the man pages, but I'd rather not go this route unless absolutely necessary. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com |