Re: [code][Textadept] Unable to modify context_menu

From: Franck Guadagnini <franckguadagnini.att.me.com>
Date: Sun, 06 Aug 2017 22:19:33 +0200

Hi Robert,

Thank you, it works. It's not documented in the book either.
I had already tried with "events.INITIALIZED"—after my first email—, but it didn't work. I was trying to replace the context_menu't table by my own.

I've try again following your advice, and got it working this way:

events.connect(events.INITIALIZED, function()
  local context_menu = textadept.menu.context_menu
  local my_table = my_table

  for i =1, #my_table do
    context_menu[i] = my_table[i]
  end
end)

Not being a programmer, I'm quite proud!

Best,
Franck

> Le 6 août 2017 à 21:44, Robert Gieseke <rob.g.att.web.de> a écrit :
>
> Hi Franck,
>
> try
>
> events.connect(events.INITIALIZED, function()
> local context_menu = textadept.menu.context_menu
> context_menu[#context_menu + 1] = {'label', function() end}
> end)
>
> In textadept/menu.lua (events.connect(events.INITIALIZED,
> set_contextmenus) you can see that the menu is only set in an
> INITIALIZED event handler, so the table is still non-existing when you
> try to add to it.
>
> I think this is currently not properly documented in the manual.
>
> Cheers,
> Robert
>
> Am 06/08/17 um 09:12 schrieb Franck Guadagnini:
>> Hi,
>>
>> Where should I put code to modify context_menu?
>> textadept.menu.context_menu[#textadept.menu.context_menu + 1] = {…}
>> works from the command entry, but if set in any of my config files, I get at Textadept's start the error "attempt to get length of a nil value (field 'context_menu')".
>>
>> Best,
>> Franck--
>> You are subscribed to code.att.foicica.com.
>> To change subscription settings, send an e-mail to code+help.att.foicica.com.
>> To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
>>
>
> --
> You are subscribed to code.att.foicica.com.
> To change subscription settings, send an e-mail to code+help.att.foicica.com.
> To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
>

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sun 06 Aug 2017 - 16:19:33 EDT

This archive was generated by hypermail 2.2.0 : Mon 07 Aug 2017 - 06:43:59 EDT