Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML.Net setting window active AND music loop points  (Read 9215 times)

0 Members and 1 Guest are viewing this topic.

Tigre Pablito

  • Full Member
  • ***
  • Posts: 226
    • View Profile
    • Email
SFML.Net setting window active AND music loop points
« on: May 17, 2018, 03:31:59 am »
Hello Ladies and Guys

I would like to know if sometime, the issue about setting the window active (RenderWindow.SetActive() method), and the feature about (Music) Loop points, both of SFML.Net, will be addressed.

Thanks

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML.Net setting window active AND music loop points
« Reply #1 on: May 17, 2018, 08:21:34 am »
Quote
the issue about setting the window active (RenderWindow.SetActive() method)
What issue?

Quote
and the feature about (Music) Loop points
Will be available when SFML.Net is updated to version 2.5, which doesn't depend on us.
Laurent Gomila - SFML developer

Tigre Pablito

  • Full Member
  • ***
  • Posts: 226
    • View Profile
    • Email
Re: SFML.Net setting window active AND music loop points
« Reply #2 on: May 22, 2018, 03:48:24 pm »
Quote
the issue about setting the window active (RenderWindow.SetActive() method)
What issue?

When my poor games start, I have to click on the screen, if not, they don't respond to events (keyboard, etc). So I call window.SetActive(); but it seems it does nothing. So what I would need is a way to prescind of clicking on the screen to activate it. Maybe I'm wrong and that is not the function I have to call.


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: SFML.Net setting window active AND music loop points
« Reply #3 on: May 22, 2018, 04:07:35 pm »
SetActive() has to do with OpenGL contexts and not with window focus.

What's your minimal and complete code example?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Tigre Pablito

  • Full Member
  • ***
  • Posts: 226
    • View Profile
    • Email
Re: SFML.Net setting window active AND music loop points
« Reply #4 on: May 22, 2018, 07:21:43 pm »
Hello eXpl0it3r

If the function for focussing the window is not SetActive() I suppose the code example with it won't help us too much to solve the issue  ;D

If you could tell me which is the function that really does, it would be very nice and then if it fails, I will make the code example. Thank you!  :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML.Net setting window active AND music loop points
« Reply #5 on: May 22, 2018, 08:00:45 pm »
Since your description of the problem is not very accurate, it may be faster to show your code so that we can directly check what's wrong with it.

The function to give explicit focus to a window is setFocus, but it was added recently and may not be supported in your version of SFML.Net -- but again, without more information from you, we can just assume.
Laurent Gomila - SFML developer

Tigre Pablito

  • Full Member
  • ***
  • Posts: 226
    • View Profile
    • Email
Re: SFML.Net setting window active AND music loop points
« Reply #6 on: May 23, 2018, 03:30:52 am »
Hi Laurent

I already found the way to solve the issue of focus stolen when the game starts. My apps were of console type, and then the console box stole focus to the window. Now I changed to Windows application and it starts focused.

However, if the window lose the focus, it seems (for SFML.Net) it isn't possible to regain it from the code. As you said, we'll have to wait for the .Net update. (I searched the setFocus() function and there isn't. Rarely, there are RequestFocus(), that works fine, and another I don't remember)

I hope the SFML.Net update comes soon  :D

Thanks

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML.Net setting window active AND music loop points
« Reply #7 on: May 23, 2018, 06:39:42 am »
Yes, it may be RequestFocus, not setFocus, I don't remember the name of every new function ;D
Laurent Gomila - SFML developer

Tigre Pablito

  • Full Member
  • ***
  • Posts: 226
    • View Profile
    • Email
Re: SFML.Net setting window active AND music loop points
« Reply #8 on: May 23, 2018, 01:45:24 pm »
No, RequestFocus doesn't focus the window, it just request you to focus it, flashing its icon in the task bar with a yellow tone, like when you're debugging your app with Visual Studio and it stops at an exception.

I just was able to get the window focused when creating it (when the game starts), by changing the app target type.

But there isn't any SetFocus() function in SFML.Net for now. That would be useful in case the app loses focus while the game is running. So let's wait for SFML.Net update  :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML.Net setting window active AND music loop points
« Reply #9 on: May 23, 2018, 02:33:24 pm »
There's no SetFocus function, RequestFocus is all we implemented. There are many discussions about "stealing" vs "requesting" focus, both on this forum and on the github tracker; I let you read them if you're interested to know why we did it this way.

But anyway, since your problem is solved... :)
Laurent Gomila - SFML developer

Tigre Pablito

  • Full Member
  • ***
  • Posts: 226
    • View Profile
    • Email
Re: SFML.Net setting window active AND music loop points
« Reply #10 on: May 24, 2018, 03:50:05 am »
My first problem is solved, that is, when my poor games start, the window automatically gains focus ...

But what about if it lost focus while the game is running? ... I have to click on the screen ... also it is a bit annoying that a window appears or for some reason the game window loses focus

So it would be very nice that comes the SetFocus() function for SFML.Net to be able to regain focus when it's lost (I saw there is a LostFocus event, that would be used with it) ... If I understood well it will be added to next .Net update ... I hope so

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML.Net setting window active AND music loop points
« Reply #11 on: May 24, 2018, 08:10:09 am »
There's no setFocus in SFML C++, so there won't be a SetFocus function in SFML.Net.

Your window is not going to lose focus magically, if it does, it means that the user switched to another window so there's no point forcing the focus back to your window.

I don't want to repeat months of discussions, so please read those topics / issues that I mentioned, and if you really want to push this feature, come with real use cases and strong arguments :)
Laurent Gomila - SFML developer

Tigre Pablito

  • Full Member
  • ***
  • Posts: 226
    • View Profile
    • Email
Re: SFML.Net setting window active AND music loop points
« Reply #12 on: May 29, 2018, 02:03:49 am »
Yes, it's very improbable that the window loses focus, you're right, maybe only by an appearing window that asks you to buy further antivirus protection. For those very few cases what I'll do is handling the LostFocus event with a game pause function. Thanks for your replies.