Using BASS interface, how to make a GUI show text, like objects do?

Started by thromgrail, Sat 08/02/2025 18:22:14

Previous topic - Next topic

thromgrail

Specifically, I have a notebook GUI button in the lower right corner of the screen, when you mouse over it, I'd like the text that displays at the bottom of the screen in BASS with objects, characters, and hotspots that have descriptions, to show "Notebook." Wracking my brain but not clear how, or if, this can be done. Thanks for your time!

Kara Jo Kalinowski

You can do this inside your repeatedly_execute:

Code: ags
GUIControl *theControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (theControl == ButtonQuit) {
  LabelInfo.Text = "Quit Game";
}

Replace ButtonQuit and LabelInfo with whatever yours are called.

thromgrail

Quote from: Kara Jo Kalinowski on Sat 08/02/2025 19:03:10You can do this inside your repeatedly_execute:

Code: ags
GUIControl *theControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (theControl == ButtonQuit) {
  LabelInfo.Text = "Quit Game";
}

Replace ButtonQuit and LabelInfo with whatever yours are called.

This doesn't seem to work?

Code: ags
GUIControl *theControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (theControl == gNotebutton) {
  gNotebutton.Text = "Notebook";
}

returns an error on "if (theControl" etc.,
GlobalScript.asc(465): Error (line 465): Type mismatch: cannot convert 'GUIControl*' to 'GUI*'

Kara Jo Kalinowski

#3
Quote from: thromgrail on Sun 09/02/2025 00:59:04
Quote from: Kara Jo Kalinowski on Sat 08/02/2025 19:03:10You can do this inside your repeatedly_execute:

Code: ags
GUIControl *theControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (theControl == ButtonQuit) {
  LabelInfo.Text = "Quit Game";
}

Replace ButtonQuit and LabelInfo with whatever yours are called.

This doesn't seem to work?

Code: ags
GUIControl *theControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (theControl == gNotebutton) {
  gNotebutton.Text = "Notebook";
}

returns an error on "if (theControl" etc.,
GlobalScript.asc(465): Error (line 465): Type mismatch: cannot convert 'GUIControl*' to 'GUI*'

That would mean that you're inputting the name of the GUI and not the name of the button on the GUI.

It's possible to capture the entire GUI using GUI rather than GUIControl in the code above, but I'm guessing you just want the button.

(My code that I tested is in 3.5.1 so I'm not sure if it changed, you could try just changing GUIControl to GUI and seeing if that works.)

For example:



The gui is called gMenu and the button is called ButtonQuit.

If I wanted the entire menu to be a hotspot, I would go

Code: ags
GUI *theControl = GUI.GetAtScreenXY(mouse.x, mouse.y);
  if (theControl == gMenu) {
    LabelInfo.Text = "Menu";
  }

But I want just the button, so I did it as posted above.

thromgrail

My apologies. I called it a button since I made it function as a button, but it's just a GUI. Attempting to use GUI returns this error:

GlobalScript.asc(466): Error (line 466): '.Text' is not a public member of 'GUI'. Are you sure you spelt it correctly (remember, capital letters are important)?

It's possible I don't know what to use instead of LabelInfo, my code is as follows:

Code: ags
  GUI *theControl = GUI.GetAtScreenXY(mouse.x, mouse.y);
  if (theControl == gNotebutton) {
    gNotebutton.Text = "Notebook";
  }

Kara Jo Kalinowski

Quote from: thromgrail on Sun 09/02/2025 01:35:31My apologies. I called it a button since I made it function as a button, but it's just a GUI. Attempting to use GUI returns this error:

GlobalScript.asc(466): Error (line 466): '.Text' is not a public member of 'GUI'. Are you sure you spelt it correctly (remember, capital letters are important)?

It's possible I don't know what to use instead of LabelInfo, my code is as follows:

Code: ags
  GUI *theControl = GUI.GetAtScreenXY(mouse.x, mouse.y);
  if (theControl == gNotebutton) {
    gNotebutton.Text = "Notebook";
  }

What is the name of the label containing the text?

i.e.



It'd be the thing your existing text update code is modifying.

thromgrail

AHA! I wanted to change the label in the BASS ActionBar. I created an unclickable button (clicking the GUI itself does the functions) with the same image I wanted, and did this:

Code: ags
  GUIControl *theControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (theControl == notebutt) {
  lblAction.Text = "Notebook";
}

Now it shows at the bottom of the screen and still functions normally. Thank you very much for your assistance! And thank you very much for your patience!

Kara Jo Kalinowski

Quote from: thromgrail on Sun 09/02/2025 01:46:40AHA! I wanted to change the label in the BASS ActionBar. I created an unclickable button (clicking the GUI itself does the functions) with the same image I wanted, and did this:

Code: ags
  GUIControl *theControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (theControl == notebutt) {
  lblAction.Text = "Notebook";
}

Now it shows at the bottom of the screen and still functions normally. Thank you very much for your assistance! And thank you very much for your patience!

Yes sorry, I didn't check what the label was called beforehand, since I made my own GUI and was testing it on that. Glad you got it working :)

SMF spam blocked by CleanTalk