Sha256: c5c2d06ac474978f7bea180775f585e3a6829c1f20ce6f35341663a85ec102a0

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.
# 
# Some parts are
# Copyright 2004-2007, wxRuby development team
# released under the MIT-like wxRuby2 license

# Pure-ruby implementation of the corresponding Wx class. Simply shows
# the Window's help text in a tooltip.

class Wx::SimpleHelpProvider < Wx::HelpProvider
  def initialize
    super
    # Store for mapping windows -> help strings
    @help_wins = {} 
    # Store for mapping ids -> help strings
    @help_ids  = {}
  end

  # This is what is called by Wx::Window#set_help_text
  def add_help(identifier, text)
    if identifier.kind_of? Wx::Window
      @help_wins[identifier.object_id] = text
    else
      @help_ids[identifier] = text
    end
  end

  # Retrieve help text for the given window +win+
  def get_help(win)
    @help_wins[win.object_id] || @help_ids[win.wx_id] || ""
  end

  # Remove the help text for +win+
  def remove_help(win)
    @help_wins.delete(win.object_id)
  end

  # Show help for +win+
  def show_help(win)
    help_text = get_help(win)
    return false if help_text.empty?
    tip = Wx::TipWindow.new(win, help_text, 100)
    true
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wxruby3-0.9.7-x64-mingw-ucrt lib/wx/core/simplehelpprovider.rb
wxruby3-0.9.5-x64-mingw-ucrt lib/wx/core/simplehelpprovider.rb
wxruby3-0.9.4-x64-mingw-ucrt lib/wx/core/simplehelpprovider.rb
wxruby3-0.9.3-x64-mingw-ucrt lib/wx/core/simplehelpprovider.rb
wxruby3-0.9.2-x64-mingw-ucrt lib/wx/core/simplehelpprovider.rb
wxruby3-0.9.1-x64-mingw-ucrt lib/wx/core/simplehelpprovider.rb
wxruby3-0.9.0-x64-mingw-ucrt lib/wx/core/simplehelpprovider.rb