How to define own tooltip text

UrbanCyborg
Posts: 588
Joined: Mon Nov 15, 2021 9:23 pm

Re: How to define own tooltip text

Post by UrbanCyborg »

What I was thinking was that if the control was visible, but picked out in non-visible colors, save for its hover color, it should generate tool tips. No?

Reid
Cyberwerks Heavy Industries -- viewforum.php?f=76
User avatar
ChR_is
Posts: 106
Joined: Wed Sep 22, 2021 5:48 pm

Re: How to define own tooltip text

Post by ChR_is »

you must keep the button visible, but use an invisible skin for the tooltip to work. To create an invisible skin just create an empty svg and use the skin editor to set this svg for normal state of a button skin.

i found that SetEnabled(false) and SetVisible(false) disable tooltips.

also make sure that you have the z-order correct so that the button is placed above the label. you have to make up your mind which control shall interact with your mouse. if you place the button at the top, the label won't receive mouse notification any longer and vice versa ;)
User avatar
ChR_is
Posts: 106
Joined: Wed Sep 22, 2021 5:48 pm

Re: How to define own tooltip text

Post by ChR_is »

seal58 wrote: Mon Jan 30, 2023 10:08 am
For my module I just need to use the labels with "Number Editor" options. So regular ToolTipText function seems not to be usable for me.
if the label needs to be editable (aka must consume mouse events as well) it's a bit more tricky tbh. if i were to solve that, i'd probably try with creating an edit-able label (single-click editing) above an invisible button which in turn is above a simple non-editable label.

Code: Select all

void InitializeControls()
{
        textLabel1 = new VoltageLabel( "textLabel1", "textLabel1", this, "Text" );
        AddComponent( textLabel1 );
        textLabel1.SetWantsMouseNotifications( false );
        textLabel1.SetPosition( 32, 183 );
        textLabel1.SetSize( 80, 30 );
        textLabel1.SetEditable( false, false );
        textLabel1.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
        textLabel1.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
        textLabel1.SetColor( new Color( 255, 255, 255, 255 ) );
        textLabel1.SetBkColor( new Color( 65, 65, 65, 0 ) );
        textLabel1.SetBorderColor( new Color( 0, 0, 0, 0 ) );
        textLabel1.SetBorderSize( 1 );
        textLabel1.SetMultiLineEdit( false );
        textLabel1.SetIsNumberEditor( false );
        textLabel1.SetNumberEditorRange( 0, 100 );
        textLabel1.SetNumberEditorInterval( 1 );
        textLabel1.SetNumberEditorUsesMouseWheel( false );
        textLabel1.SetHasCustomTextHoverColor( false );
        textLabel1.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
        textLabel1.SetFont( "<Sans-Serif>", 14, false, false );

        button1 = new VoltageButton( "button1", "button1", this );
        AddComponent( button1 );
        button1.SetWantsMouseNotifications( false );
        button1.SetPosition( 54, 181 );
        button1.SetSize( 37, 37 );
        button1.SetSkin( "InvisibleButton" );
        button1.ShowOverlay( false );
        button1.SetOverlayText( "" );
        button1.SetAutoRepeat( false );

        editableText1 = new VoltageLabel( "editableText1", "editableText1", this, "TEST" );
        AddComponent( editableText1 );
        editableText1.SetWantsMouseNotifications( false );
        editableText1.SetPosition( 32, 184 );
        editableText1.SetSize( 80, 30 );
        editableText1.SetEditable( true, false );
        editableText1.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
        editableText1.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
        editableText1.SetColor( new Color( 255, 255, 255, 255 ) );
        editableText1.SetBkColor( new Color( 65, 65, 65, 0 ) );
        editableText1.SetBorderColor( new Color( 0, 0, 0, 0 ) );
        editableText1.SetBorderSize( 1 );
        editableText1.SetEditTextColor( new Color( 0, 0, 0 ) );
        editableText1.SetEditBackColor( new Color( 65, 65, 65, 0 ) );
        editableText1.SetEditOutlineColor( new Color( 0, 0, 0, 0 ) );
        editableText1.SetMultiLineEdit( false );
        editableText1.SetIsNumberEditor( false );
        editableText1.SetNumberEditorRange( 0, 100 );
        editableText1.SetNumberEditorInterval( 1 );
        editableText1.SetNumberEditorUsesMouseWheel( false );
        editableText1.SetHasCustomTextHoverColor( false );
        editableText1.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
        editableText1.SetFont( "<Sans-Serif>", 14, false, false );
}
.

the topmost label must be hidden

Code: Select all

public void Initialize()
    {
        editableText1.SetVisible( false );
    }

the button provides the tooltip

Code: Select all

public String GetTooltipText( VoltageComponent component )
    {
        if( component == button1 )
        {
            return "Button Tooltip";
        }
    }
when the button is triggered make the topmost label visible again and the regular text label insivible

Code: Select all

case Button_Changed:   // doubleValue is the new button/toggle button value
            {                
                if( component == button1 && doubleValue > 0.5 )
                {
                    textLabel1.SetVisible( false );
                    editableText1.SetVisible( true );
                    return true;
                }
            }
when done editing reverse the process

Code: Select all

case Label_Changed:        // The text of an editable text control has changed
            {
                if( component == editableText1 )
                {
                    textLabel1.SetText( editableText1.GetText() );
                    textLabel1.SetVisible( true );
                    editableText1.SetVisible( false );
                    return true;
                }
            }
since the editable text label is activated by single-click, it doesn't matter that the first click is consumed by the button. to the user it'll feel like a regular double click.

The issue with this process is that when the text is not changed, it breaks. but i think that's a valid starting point to experiment with. you could probably get away with pre-setting the editable text label with a marker text like "edit here" to make it different to what it was before in order to trigger the Label_Changed event. good luck ;)


here's the full vmd to try out (you might need to replace the button skin though):

Code: Select all

package com.mycompany.newmodule;


import voltage.controllers.*;
import voltage.core.*;
import voltage.core.Jack.JackType;
import voltage.sources.*;
import voltage.utility.*;
import voltage.processors.*;
import voltage.effects.*;
import java.awt.*;

// Add your own imports here





public class MyModule extends VoltageModule

{

    public MyModule( long moduleID, VoltageObjects voltageObjects )
    {
        super( moduleID, voltageObjects, "My Module", ModuleType.ModuleType_Utility, 2.0 );

        InitializeControls();


        canBeBypassed = false;
        SetSkin( "2ae1754985404566929d2f5237ff7b26" );
    }

void InitializeControls()
{

        textLabel1 = new VoltageLabel( "textLabel1", "textLabel1", this, "Text" );
        AddComponent( textLabel1 );
        textLabel1.SetWantsMouseNotifications( false );
        textLabel1.SetPosition( 32, 183 );
        textLabel1.SetSize( 80, 30 );
        textLabel1.SetEditable( false, false );
        textLabel1.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
        textLabel1.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
        textLabel1.SetColor( new Color( 255, 255, 255, 255 ) );
        textLabel1.SetBkColor( new Color( 65, 65, 65, 0 ) );
        textLabel1.SetBorderColor( new Color( 0, 0, 0, 0 ) );
        textLabel1.SetBorderSize( 1 );
        textLabel1.SetMultiLineEdit( false );
        textLabel1.SetIsNumberEditor( false );
        textLabel1.SetNumberEditorRange( 0, 100 );
        textLabel1.SetNumberEditorInterval( 1 );
        textLabel1.SetNumberEditorUsesMouseWheel( false );
        textLabel1.SetHasCustomTextHoverColor( false );
        textLabel1.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
        textLabel1.SetFont( "<Sans-Serif>", 14, false, false );

        button1 = new VoltageButton( "button1", "button1", this );
        AddComponent( button1 );
        button1.SetWantsMouseNotifications( false );
        button1.SetPosition( 54, 181 );
        button1.SetSize( 37, 37 );
        button1.SetSkin( "InvisibleButton" );
        button1.ShowOverlay( false );
        button1.SetOverlayText( "" );
        button1.SetAutoRepeat( false );

        editableText1 = new VoltageLabel( "editableText1", "editableText1", this, "TEST" );
        AddComponent( editableText1 );
        editableText1.SetWantsMouseNotifications( false );
        editableText1.SetPosition( 32, 184 );
        editableText1.SetSize( 80, 30 );
        editableText1.SetEditable( true, false );
        editableText1.SetJustificationFlags( VoltageLabel.Justification.HorizCentered );
        editableText1.SetJustificationFlags( VoltageLabel.Justification.VertCentered );
        editableText1.SetColor( new Color( 255, 255, 255, 255 ) );
        editableText1.SetBkColor( new Color( 65, 65, 65, 0 ) );
        editableText1.SetBorderColor( new Color( 0, 0, 0, 0 ) );
        editableText1.SetBorderSize( 1 );
        editableText1.SetEditTextColor( new Color( 0, 0, 0 ) );
        editableText1.SetEditBackColor( new Color( 65, 65, 65, 0 ) );
        editableText1.SetEditOutlineColor( new Color( 0, 0, 0, 0 ) );
        editableText1.SetMultiLineEdit( false );
        editableText1.SetIsNumberEditor( false );
        editableText1.SetNumberEditorRange( 0, 100 );
        editableText1.SetNumberEditorInterval( 1 );
        editableText1.SetNumberEditorUsesMouseWheel( false );
        editableText1.SetHasCustomTextHoverColor( false );
        editableText1.SetTextHoverColor( new Color( 0, 0, 0, 255 ) );
        editableText1.SetFont( "<Sans-Serif>", 14, false, false );
}



    //-------------------------------------------------------------------------------
    //  public void Initialize()

        //  Initialize will get called shortly after your module's constructor runs. You can use it to
        //  do any initialization that the auto-generated code doesn't handle.
    //-------------------------------------------------------------------------------
    @Override
    public void Initialize()
    {
        // add your own code here

        editableText1.SetVisible( false );


    }


    //-------------------------------------------------------------------------------
    //  public void Destroy()

        //  Destroy will get called just before your module gets deleted. You can use it to perform any
        //  cleanup that's not handled automatically by Java.
    //-------------------------------------------------------------------------------
    @Override
    public void Destroy()
    {
        super.Destroy();
        // add your own code here



    }


    //-------------------------------------------------------------------------------
    //  public boolean Notify( VoltageComponent component, ModuleNotifications notification, double doubleValue, long longValue, int x, int y, Object object )

        //  Notify will get called when various events occur - control values changing, timers firing, etc.
    //-------------------------------------------------------------------------------
    @Override
    public boolean Notify( VoltageComponent component, ModuleNotifications notification, double doubleValue, long longValue, int x, int y, Object object )
    {
        // add your own code here
        switch( notification )
        {
            case Button_Changed:   // doubleValue is the new button/toggle button value
            {                
                if( component == button1 && doubleValue > 0.5 )
                {
                    textLabel1.SetVisible( false );
                    editableText1.SetVisible( true );
                    return true;
                }
            }
            break;
            case Label_Changed:        // The text of an editable text control has changed
            {
                if( component == editableText1 )
                {
                    textLabel1.SetText( editableText1.GetText() );
                    textLabel1.SetVisible( true );
                    editableText1.SetVisible( false );
                    return true;
                }
            }
            break;
        }



        return false;
    }


    //-------------------------------------------------------------------------------
    //  public void ProcessSample()

        //  ProcessSample is called once per sample. Usually it's where you read
        //  from input jacks, process audio, and write it to your output jacks.
        //  Since ProcesssSample gets called 48,000 times per second, offload CPU-intensive operations
        //  to other threads when possible and avoid calling native functions.
    //-------------------------------------------------------------------------------
    @Override
    public void ProcessSample()
    {
        // add your own code here



    }


    //-------------------------------------------------------------------------------
    //  public String GetTooltipText( VoltageComponent component )

        //  Gets called when a tooltip is about to display for a control. Override it if
        //  you want to change what the tooltip displays - if you want a knob to work in logarithmic fashion,
        //  for instance, you can translate the knob's current value to a log-based string and display it here.
    //-------------------------------------------------------------------------------
    @Override
    public String GetTooltipText( VoltageComponent component )
    {
        // add your own code here
        
        if( component == button1 )
        {
            return "Button Tooltip";
        }


        return super.GetTooltipText( component );
    }


    //-------------------------------------------------------------------------------
    //  public void EditComponentValue( VoltageComponent component, double newValue, String newText )

        //  Gets called after a user clicks on a tooltip and types in a new value for a control. Override this if
        //  you've changed the default tooltip display (translating a linear value to logarithmic, for instance)
        //  in GetTooltipText().
    //-------------------------------------------------------------------------------
    @Override
    public void EditComponentValue( VoltageComponent component, double newValue, String newText )
    {
        // add your own code here



        super.EditComponentValue( component, newValue, newText );
    }


    //-------------------------------------------------------------------------------
    //  public void OnUndoRedo( String undoType, double newValue, Object optionalObject )

        //  If you've created custom undo events via calls to CreateUndoEvent, you'll need to
        //  process them in this function when they get triggered by undo/redo actions.
    //-------------------------------------------------------------------------------
    @Override
    public void OnUndoRedo( String undoType, double newValue, Object optionalObject )
    {
        // add your own code here



    }


    //-------------------------------------------------------------------------------
    //  public byte[] GetStateInformation()

        //  Gets called when the module's state gets saved, typically when the user saves a preset with
        //  this module in it. Voltage Modular will automatically save the states of knobs, sliders, etc.,
        //  but if you have any custom state information you need to save, return it from this function.
    //-------------------------------------------------------------------------------
    @Override
    public byte[] GetStateInformation()
    {
        // add your own code here



        return null;
    }


    //-------------------------------------------------------------------------------
    //  public void SetStateInformation(byte[] stateInfo)

        //  Gets called when this module's state is getting restored, typically when a user opens a preset with
        //  this module in it. The stateInfo parameter will contain whatever custom data you stored in GetStateInformation().
    //-------------------------------------------------------------------------------
    @Override
    public void SetStateInformation(byte[] stateInfo)
    {
        // add your own code here



    }


    //-------------------------------------------------------------------------------
    //  public byte[] GetStateInformationForVariations()

        //  Gets called when a user saves a variation with this module in it.
        //  Voltage Modular will automatically save the states of knobs, sliders, etc.,
        //  but if you have any custom state information you need to save, return it from this function.
    //-------------------------------------------------------------------------------
    @Override
    public byte[] GetStateInformationForVariations()
    {
        // add your own code here



        return GetStateInformation();
    }


    //-------------------------------------------------------------------------------
    //  public void SetStateInformationForVariations(byte[] stateInfo)

        //  Gets called when a user loads a variation with this module in it.
        //  The stateInfo parameter will contain whatever custom data you stored in GetStateInformationForVariations().
    //-------------------------------------------------------------------------------
    @Override
    public void SetStateInformationForVariations(byte[] stateInfo)
    {
        // add your own code here
        SetStateInformation(stateInfo);



    }


    // Auto-generated variables
private VoltageLabel editableText1;
private VoltageLabel textLabel1;
private VoltageButton button1;


    // Add your own variables and functions here





}
User avatar
seal58
Posts: 351
Joined: Fri Jul 12, 2019 5:28 pm
Location: Rostock, Germany
Contact:

Re: How to define own tooltip text

Post by seal58 »

Hello Chris,

thanks for using your time to explain your proposal for a newby as I am still. It's really tricky. But I think I've understood the way I could go now. :)

Roland
User avatar
Aarnville
Posts: 43
Joined: Sat Jun 18, 2022 5:14 pm

Re: How to define own tooltip text

Post by Aarnville »

It's probably also worth mentioning that you have no control over where the tooltip displays - it seems to depend on where you are in the VM window so sometimes it might obscure stuff that you don't want it to.
User avatar
seal58
Posts: 351
Joined: Fri Jul 12, 2019 5:28 pm
Location: Rostock, Germany
Contact:

Re: How to define own tooltip text

Post by seal58 »

You are right, Ian

Fortunately most tooltip appear just beside ore ontop of hovered control element.

I mean that default tooltip delay is a little to short. It's only about one second. So sometimes it is not welcome to me. I'd like a longer delay of 1.5 to 2 seconds.

Roland
Post Reply

Return to “Module Designer”