[1/2 Solved] Help: Convert a Button in a Checkbox. | Popup with tree

I have some rather absurd doubts about several elements, to get a clearer display and occupy less space.

The first is convert a Button in a Checkbox.

  • The checkbox has a “V” of verification (check), allows to remain on and off.
  • The button is a pushbutton,Returns to its initial state.

My intention is to build the buttons as these (with on, off):

7107 button-on-off.png

Code Lua related:

The checkbox:

DCSP_CB_A01 = vb:checkbox {
  id = 'cbox_bars', tooltip = 'Show/Hide the Bars bellow',
  notifier = function(i) show_cbox_bars(i) end
}

The button:

DCSP_BT_A01 = vb:button {
  id = 'DCSP_BT_A01',
  tooltip = 'Insert A01',
  --bitmap = "Icons/piano.bmp",
  text = 'VOL',
  --color = PEST.CR.BT_F01,
  width = 24,
  height = 24,
  notifier = function()dcsp_F01() end
}

The second thing is to know if it is possible to skip some lines from the list inside the popup to navigate, for example, the arrows marked in red color:

7109 popup-tree.png

A example of expanded popup:

PEST_PP_A01 = vb:popup { id = 'PEST_PP_A01', width = 198 , height = 24, value = 1, items = {
    ' ORCHESTRA INSTRUMENTS ↷', -- disable or jump
    ' Strings ↷', -- disable or jump
    ' 01. Solo String',
    ' 02. First Violins',
    ' 03. Second Violins',
    ' 04. Violas',
    ' 05. Cellos',
    ' 06. Basses',
    ' Woodwinds ↷', -- disable or jump
    ' 01) Solo Woodwind',
    ' 02) Flute',
    ' 03) Piccolo',
    ' 04) Clarinet',
    ' 05) Bass Clarinet',
    ' 06) Oboe',
    ' 07) English Horn',
    ' 08) Basson',
    ' 09) Contrabasson',
    ' 10) Bagpipe',
    ' 11) Shakuhachi',
    ' 12) Saxophone',
    ' 13) Cornet',
    ' 14) Harmonica',
    ' Brasses ↷', -- disable
    ' 01) Solo Bass',
    ' 02) Trumpet',
    ' 03) French Horn',
    ' 04) Trombone',
    ' 05) Tuba',
    ' Keyboards ↷', -- disable or jump
    ' 01) Harp',
    ' 02) Piano',
    ' 03) Organ',
    ' 04) Synthesizer',
    ' 05) Harpsichord',
    ' 06) Celesta',
    ' 07) Accordion',
    ' Percussion ↷', -- disable or jump
    ' 01) Timpani',
    ' 02) Snare Drum',
    ' 03) Bass Drumm',
    ' 04) Tenor Drumm',
    ' 05) Cymbals',
    ' 06) Congas',
    ' 07) Tubular Bells',
    ' 08) Triangle',
    ' 09) Xylophone',
    ' 10) Vibraphone',
    ' 11) Hammer',
    ' 12) Glockenspiel',
    ' 13) Wooden-block',
    ' 14) Claves',
    ' 15) Chimes',
    ' 16) Marimba',
    ' 17) Tambourine',
    ' 18) Maracas',
    ' 19) Castanets',
    ' Voices ↷', -- disable or jump
    ' 01) Soprano',
    ' 02) Mezzo-Soprano',
    ' 03) Alto (Voice)',
    ' 04) Countertenor',
    ' 05) Tenor',
    ' 06) Baritone',
    ' 07) Bass (Voice)',
    ' Chorus ↷', -- disable or jump
    ' 01) Mixed Voices',
    ' 02) Women Voices',
    ' 03) Men Voices',
    ' 04) Children Voices'
  }
}

The objective is to prevent selection of some lines. It’s possible?

Any ideas for these two things?

Thanks!

  1. It’s not possible to set a button to a pressed state in the viewbuilder API. You have to ‘simulate’ this by changing the background color of the button. (It’s possible to get the correct color from global preferences, but it’s a rather technical task that I won’t go into)

  2. Not possible. The API doesn’t have access to where your cursor is until you make the actual selection.

However, in this case it might at least be better than nothing that “01) Solo woodwind” is selected if the user selects “Woodwinds”? That’s not very difficult to fix (detect that an “invalid” entry has been selected, and change the value +1)

1)Yes, I have assumed that it is possible to “simulate” by changing 2 things, color (green / red), and text (on / off). It would be an example to have it available to create other buttons this way.But I’m not sure how to solve it.

Then, two ways to do this, changing 2 colors using global preferences. This button case would be useful in many scenarios for me.Maybe Danoise has already created some button for some of its tools.

  1. Yes, that is, when selecting the unwanted, jump to the next line, that would be fine.I guess there would be 2 things here: control with keyboard, that can go up and down(would be jump up or down, according to the key) and click with the mouse (always jump down, to the next line in the list).

In this case,I would only use it in a few lists, about four. If the code were complicated, it would be no problem.

Any help with both codes would be great!

Topic Button-checkbox fixed!

I have been experimenting with the button and switch code and I have managed to merge it in a very literal and simple way. Surprised by this:

VALUEBOX_PEST_TRNTC = vb:valuebox { id = 'vbox_pest_trntc', value = 1, notifier = function(i) show_trntc(i) end, tooltip = 'Note Column Track', width = 50, height = 22, min = 1, max = 12 }
VALUEBOX_PEST_TRFXT = vb:valuebox { id = 'vbox_pest_trfxt', value = 0, notifier = function(i) show_trfxt(i) end, tooltip = 'FXt Column Track', width = 50, height = 22, min = 0, max = 8 }

vb:checkbox { id = 'cbox_pest_trvol', notifier = function(i) show_trvol(i) end, value = true } --Buttoncheck VOL
BUTTONCHECK_PEST_TRVOL = vb:button {
  id = 'beck_pest_trvol',
  width = 40,
  height = 22,
  text = 'VOL',
  color = {0x00 , 0x70 , 0x00 },
  notifier = function()
    if vb.views['cbox_pest_trvol'].value == false then
       vb.views['cbox_pest_trvol'].value = true
       vb.views['beck_pest_trvol'].color = { 0x00 , 0x70 , 0x00 }
      else
       vb.views['cbox_pest_trvol'].value = false
       vb.views['beck_pest_trvol'].color = { 0x50 , 0x00 , 0x00 }
    end
  end
}

vb:checkbox { id = 'cbox_pest_trpan', notifier = function(i) show_trpan(i) end, value = false } --Buttoncheck PAN
BUTTONCHECK_PEST_TRPAN = vb:button {
  id = 'beck_pest_trpan',
  width = 40,
  height = 22,
  text = 'PAN',
  color = {0x50 , 0x00 , 0x00 },
  notifier = function()
    if vb.views['cbox_pest_trpan'].value == false then
       vb.views['cbox_pest_trpan'].value = true
       vb.views['beck_pest_trpan'].color = { 0x00 , 0x70 , 0x00 }
      else
       vb.views['cbox_pest_trpan'].value = false
       vb.views['beck_pest_trpan'].color = { 0x50 , 0x00 , 0x00 }
    end
  end
}

vb:checkbox { id = 'cbox_pest_trdly', notifier = function(i) show_trdly(i) end, value = false } --Buttoncheck DLY
BUTTONCHECK_PEST_TRDLY = vb:button {
  id = 'beck_pest_trdly',
  width = 40,
  height = 22,
  text = 'DLY',
  color = {0x50 , 0x00 , 0x00 },
  notifier = function()
    if vb.views['cbox_pest_trdly'].value == false then
       vb.views['cbox_pest_trdly'].value = true
       vb.views['beck_pest_trdly'].color = { 0x00 , 0x70 , 0x00 }
      else
       vb.views['cbox_pest_trdly'].value = false
       vb.views['beck_pest_trdly'].color = { 0x50 , 0x00 , 0x00 }
    end
  end
}

vb:checkbox { id = 'cbox_pest_trsfx', notifier = function(i) show_trsfx(i) end, value = false } --Buttoncheck SFX
BUTTONCHECK_PEST_TRSFX = vb:button {
  id = 'beck_pest_trsfx',
  width = 40,
  height = 22,
  text = 'sFX',
  color = {0x50 , 0x00 , 0x00 },
  notifier = function()
    if vb.views['cbox_pest_trsfx'].value == false then
       vb.views['cbox_pest_trsfx'].value = true
       vb.views['beck_pest_trsfx'].color = { 0x00 , 0x70 , 0x00 }
      else
       vb.views['cbox_pest_trsfx'].value = false
       vb.views['beck_pest_trsfx'].color = { 0x50 , 0x00 , 0x00 }
    end
  end
}

DEFAULT_PEST_PARAM = vb:button {
  id = 'def_pest_param',
  width = 70,
  height = 22,
  text = 'DEFAULT',
  color = { 0x8E , 0x39 , 0x00 },
  notifier = function()
    if vb.views['cbox_pest_trvol'].value == false then
       vb.views['cbox_pest_trvol'].value = true
       vb.views['beck_pest_trvol'].color = { 0x00 , 0x70 , 0x00 }
       else
       vb.views['cbox_pest_trvol'].value = true
       vb.views['beck_pest_trvol'].color = { 0x00 , 0x70 , 0x00 }
    end

    if vb.views['cbox_pest_trpan'].value == true then
       vb.views['cbox_pest_trpan'].value = false
       vb.views['beck_pest_trpan'].color = { 0x50 , 0x00 , 0x00 }
       else
       vb.views['cbox_pest_trpan'].value = false
       vb.views['beck_pest_trpan'].color = { 0x50 , 0x00 , 0x00 }
    end       
    if vb.views['cbox_pest_trdly'].value == true then
       vb.views['cbox_pest_trdly'].value = false
       vb.views['beck_pest_trdly'].color = { 0x50 , 0x00 , 0x00 }
       else
       vb.views['cbox_pest_trdly'].value = false
       vb.views['beck_pest_trdly'].color = { 0x50 , 0x00 , 0x00 }
    end
    if vb.views['cbox_pest_trsfx'].value == true then
       vb.views['cbox_pest_trsfx'].value = false
       vb.views['beck_pest_trsfx'].color = { 0x50 , 0x00 , 0x00 }
       else
       vb.views['cbox_pest_trsfx'].value = false
       vb.views['beck_pest_trsfx'].color = { 0x50 , 0x00 , 0x00 }       
    end
    
    if vb.views['vbox_pest_trntc'].value > 0 then
       vb.views['vbox_pest_trntc'].value = 1
       else
       vb.views['vbox_pest_trntc'].value = 1
    end
    if vb.views['vbox_pest_trfxt'].value >= 0 then
       vb.views['vbox_pest_trfxt'].value = 0
       else
       vb.views['vbox_pest_trfxt'].value = 0
    end
  end
}

It’s funny, but it works perfectly! Fusion!!! :slight_smile:

7138 button-checkbox-fusion.png

(…the buttons below).I love it!!!

The topic of the popup I do not know how to solve it to skip lines, it is more convoluted…