Can a function disable property?

I have resizeable buttons in my tool, and when button height is more than 17, I’d like it to display text. If less - no text.

So, I’m trying to do sometning like this

local function text_or_not(h)
		if h > 17 then
			return someText
			else
			return ""
             --return nil
		end
	end
	
	vb:button { 
		height = h,               
		text = text_or_not(h)
	}

If return nil, it shows error. If return “” then no text is shown, BUT button behaves like it contains text, i.e. it’s height equals font height, which is not good. What should I do?

A blank string is still considered a string, so the button will use the minimum height that the font allows.

Setting the button text to nil instead will allow you to freely resize it, even down to 1 or 2 pixels high if you really wish.

I quickly tested your function here but modified it to return nil instead of “”, and it seemed to work just fine.

local function text_or_not(h)
  if h > 17 then
    return "Awesome Button"
  else
    return nil
  end
end

What is the exact error you’re getting?

Are you sure it’s caused by that portion of your code, and not something else nearby?

Now it works, sorry.

Same thing happened yesterday when song():undo() was freezing Renoise. I was going to post a question already but then Renoise restarted and the problem was gone by itself.

Here is a more compact alternative, if you prefer:

vb:button {
  height = h,
  text = h > 17 and "Awesome Button" or nil
}

Here is a more compact alternative

Thank you! I knew this construction but it slipped my mind