Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: dce47d76e14a02e7346059ec55eb3eed0eff29621c714bdbece2aca0c9d6e398
Ticket: 91b3a5bb14e6e8ae1d1c5349af12e08879ea152d
msgcat with oo: error "self may only be called from inside a method"
User & Date: oehhar on 2024-07-15 13:08:21
Changes

  1. icomment:
    Hi Donal,
    thanks for the investigation.
    
    Here is my reproduction script:
    
    <verbatim>
    package require msgcat
    oo::class create App {}
    oo::define App {
        constructor {} { my add_one }
        method add_one {} { recordMsgcat }
    }
    proc recordMsgcat {} { set ::nscaller [uplevel 1 {namespace current}] }
    set application [App new]
    namespace eval $::nscaller [list ::msgcat::mc "Test"]
    </verbatim>
    
    This is now in checkin [5c3ab23c5e].
    
    To try the whole resolution block is in checkin [62e3c281e5].
    
    -----
    
    I think, tktooltip should directly call msgcat on setup and not later.
    This will not allow to change the language, but will resolve for this case.
    
    I am anyway unhappy to use msgcat in the tooltip implicitly.
    
    -----
    
    To do this properly, you recomment to have a function which gets the "msgcat namespace key" which will basically call "PackageNamespaceGet", if it would be stored. That sounds reasonable.
    
    Thanks again,
    Harald
    
  2. login: "oehhar"
  3. mimetype: "text/x-fossil-wiki"
  4. username: "oehhar"