Module: Teek::UI::WindowRealize Private

Defined in:
lib/teek/ui/widget_types/window.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

A freshly created :window's post-creation setup: title/geometry/ resizable setup, transient-to-parent, the macOS shared-menubar quirk (each platform other than macOS gets its own menu bar per window; macOS has a single app-wide menu bar, so without this a new window falls back to Tk's default "wish" menu instead of the parent's), and withdrawn by default - shown explicitly via Handle#show. Registered as :window's own post_create: below.

Class Method Summary collapse

Class Method Details

.post_create(app, node, path, parent_path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/teek/ui/widget_types/window.rb', line 17

def self.post_create(app, node, path, parent_path)
  opts = node.opts
  window = app.window(path)

  window.set_title(opts[:title]) if opts[:title]
  window.set_geometry(opts[:geometry]) if opts[:geometry]
  if opts.key?(:resizable)
    pair = opts[:resizable]
    width, height = pair.is_a?(Array) ? pair : [pair, pair]
    window.set_resizable(width, height)
  end
  app.command(:wm, :transient, path, parent_path) unless opts[:transient] == false
  share_macos_menu(app, path, parent_path) if Teek.platform.darwin?
  window.withdraw
end

.share_macos_menu(app, path, parent_path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
36
37
38
# File 'lib/teek/ui/widget_types/window.rb', line 33

def self.share_macos_menu(app, path, parent_path)
  parent_menu = app.command(parent_path, :cget, '-menu')
  app.command(path, :configure, menu: parent_menu) unless parent_menu.nil? || parent_menu.empty?
rescue Teek::TclError
  nil
end