getName with 'on-click' method?

Home Forums General Programming getName with 'on-click' method?

Tagged: 

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #83281
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    noticed that an ‘on-change’ method, using (mod,value)
    does not work if it is called from ‘on mouse click’.

    i want to do the equivalent of:

    local padName= L(mod:getName())
    local psub=tonumber(string.sub(padName,4))	--[ pad number ]--

    to handle multiple modulators using the same prefix and a number.

    ‘on click’ methods seem to appear with:
    (--[[ CtrlrComponent --]] comp, --[[ MouseEvent --]] event)

    but i can’t do:
    `local kbdName= L(comp:getName())’
    ‘componentvisibleName’ could be a possibility, but not at the
    moment, the way i’m using these components (labels… could
    change them over for buttons, which at least could produce a
    value change, if required to)

    i ask, because earlier i needed/wanted to associate a method
    with ‘on-click’ but had to stick with ‘on value change’.

    #83282
    Possemo
    Participant
    • Topics: 14
    • Replies: 638
    • Total: 652
    • ★★★

    with comp: you can only get component properties of a modulator – it is the same as panel:getComponent… If someone else knows how to get modulator properties I would be interested too.

    #83283
    dasfaker
    Keymaster
    • Topics: 80
    • Replies: 793
    • Total: 873
    • ★★★

    with comp: you can only get component properties of a modulator – it is the same as panel:getComponent… If someone else knows how to get modulator properties I would be interested too.

    comp:getOwner()

    #83284
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    comp:getOwner():getName()?

    #83285
    dasfaker
    Keymaster
    • Topics: 80
    • Replies: 793
    • Total: 873
    • ★★★

    comp:getOwner():getName()?

    With this you get the name of the owner

    #83286
    Possemo
    Participant
    • Topics: 14
    • Replies: 638
    • Total: 652
    • ★★★

    Thanks a lot dasfaker. That’s it!

    #83288
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    great, thanks for that insight 😉

    #83289
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    doing something with that as:
    (messing around with an array of labels as keyboard notes)

    function kybdOps(comp, event)
    	kbName	=nil
    	kbsub	=nil
     
    	kbName= L(comp:getOwner():getName())
    	kbsub=tonumber(string.sub(kbName,3))
    	--console(String(kbName..":"..kbsub))
    
    	matchkbsub()
    
    end

    where ‘matchkbsub’ does stuff with tables
    -trying to figure out a way to do a graphic keyboard,
    and if labels are viable – maybe buttons? but you have
    fewer text appearance options, so for now it’s labels,
    which will display what’s assigned to a key (eventually).

    #83311
    goodweather
    Participant
    • Topics: 45
    • Replies: 550
    • Total: 595
    • ★★★

    Please look at my Pro2 panel…
    xxx_OnChange and xxx_OnClick methods are different.

    When you create an xxx_OnChange method, you select luaModulatorValueChange
    and the declaration is:
    xxx_OnChange = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source)

    When you create an xxx_OnClick method, you select componentLuaMouseDown
    and the declaration is:
    xxx_OnClick = function(--[[ CtrlrComponent --]] comp, --[[ MouseEvent --]] event)

    So, in the OnChange, you have access to a modulator while in the OnClick you have access to the component.
    In the OnClick method, to get the name of the parent modulator of a component you need to use
    sName= L(comp:getOwner():getName())

    From there it is easy to re-use the same OnClick for several modulators…
    OSC1Freq, OSC2Freq, OSC3Freq…
    Just get the name then isolate the 4 first characters (or only the 4th one) with string.sub and build a classical if..then…elseif…elseif…end check

    #83312
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    good explanation – particularly distinction for
    modulator or component – thanks.

    (and so… : the finer points of Mouse events?)

Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘Programming’ is closed to new topics and replies.
There is currently 0 users and 60 guests online
No users are currently active
Forum Statistics
Threads: 2,495, Posts: 17,374, Members: 77,605
Most users ever online was 12 on January 22, 2019 3:47 pm
Ctrlr