GMBR
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.
Entrar

Esqueci-me da senha

Últimos assuntos
» Problema ao entrar por uma porta e voltar por ela
por aminaro Seg 06 maio 2024, 10:08

» Alguém aqui já ganha dinheiro com seus games?
por theguitarmester Ter 30 Abr 2024, 11:43

» Colisões não funcionando
por theguitarmester Ter 30 Abr 2024, 10:16

» Como ajustar velocidade de cada frame da animação no game maker
por pequetux Sex 26 Abr 2024, 16:45

» Preciso de ajuda
por AftonDuGrau Dom 21 Abr 2024, 20:18

» Como faz o evento drawn GUI, não se repetir?
por aminaro Sex 19 Abr 2024, 20:30

» PROBLEMAS COM FÍSICAS DE ÁGUA
por aminaro Ter 16 Abr 2024, 10:07

» Retorno da GMBR!!!
por Ralphed Sex 12 Abr 2024, 22:45

» JOGADOR PARANDO NO AR QUANDO ATACA
por aminaro Qua 10 Abr 2024, 13:51

» Problemas com texto interativo
por Kaaru72 Dom 07 Abr 2024, 11:31

» Erro escondido e indecifrável
por dev_gabize.azv Qui 04 Abr 2024, 10:11

» Mudar cor de apenas uma palavra
por Ralphed Sáb 30 Mar 2024, 00:39

» Procuro Programador de game maker
por Wou Sex 15 Mar 2024, 10:27

» Mod APK
por gamerainha Qua 13 Mar 2024, 06:30

» Aceito pedidos de sprites (Com exemplos meus)
por Sevilha Qua 28 Fev 2024, 12:17

» Inventário simples
por Isquilo_Roedor Qui 22 Fev 2024, 15:18

» Problemas na programaçnao de inimigo [jogo DOOM LIKE]
por Black Mirror Dom 11 Fev 2024, 13:34

» ANDROID MULTI TOUCH
por DiegoBr Dom 04 Fev 2024, 12:13

» Servidor de Discord do fórum?
por Lighter Sáb 27 Jan 2024, 17:18

» Save e Load Json
por Klinton Rodrigues Qui 25 Jan 2024, 11:12

» Colisão com mais de um objeto
por aminaro Seg 22 Jan 2024, 15:02

» Oi sou novo aqui
por Thiago Silveira Alexandre Sáb 20 Jan 2024, 20:55

» Como acessar conteudo comprado no marketplace
por macmilam Sex 19 Jan 2024, 07:42

» Devlogs em vídeos do Block Room
por Joton Seg 15 Jan 2024, 16:56

» ACERVO GMBR MAGAZINE
por Joton Qui 11 Jan 2024, 19:21


[Resolvido]Como fazer uma caixa de texto para um browser web

3 participantes

Ir para baixo

[Resolvido]Como fazer uma caixa de texto para um browser web Empty [Resolvido]Como fazer uma caixa de texto para um browser web

Mensagem por afonso_silva Sex 15 Out 2010, 11:31

Olá a todos aqui do fórum!
Eu queria saber como fazer uma caixa de texto para utilizar num browser que estou a fazer, que dê para digitar os urls dos sites. Não gosto nada da função "get_string", aquela que mostra uma mensagem para a gente escrever texto. Já experimentei várias aqui do fórum, só que o problema é sempre o mesmo: quando executo o navegador, ele vai para a página do google e apesar de aparecer o sítio do texto para eu digitar, se eu escrever alguma coisa, essa coisa aparece escrita na caixa de texto do google e não na barra de endereços! e se eu retirar o objecto que desenha a página, este problema não acontece! Alguém me pode ajudar?


Última edição por afonso_silva em Dom 17 Out 2010, 14:33, editado 1 vez(es)
afonso_silva
afonso_silva

Data de inscrição : 29/05/2010
Reputação : 0
Número de Mensagens : 147
Prêmios : [Resolvido]Como fazer uma caixa de texto para um browser web Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Como fazer uma caixa de texto para um browser web Empty Re: [Resolvido]Como fazer uma caixa de texto para um browser web

Mensagem por Adriel Sex 15 Out 2010, 12:14

Pois é véio, também queria saber :|

Acho que só com get_string mesmo :|
Adriel
Adriel

Data de inscrição : 18/07/2009
Reputação : 2
Número de Mensagens : 924
Prêmios : [Resolvido]Como fazer uma caixa de texto para um browser web Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Como fazer uma caixa de texto para um browser web Empty Re: [Resolvido]Como fazer uma caixa de texto para um browser web

Mensagem por afonso_silva Sex 15 Out 2010, 14:16

Adriel escreveu:Pois é véio, também queria saber :|

Acho que só com get_string mesmo :|

Espero bem que não.
Espero que alguém nos ajude. Zangado Mad
afonso_silva
afonso_silva

Data de inscrição : 29/05/2010
Reputação : 0
Número de Mensagens : 147
Prêmios : [Resolvido]Como fazer uma caixa de texto para um browser web Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Como fazer uma caixa de texto para um browser web Empty Re: [Resolvido]Como fazer uma caixa de texto para um browser web

Mensagem por leocesar Sex 15 Out 2010, 14:46

Fiz um upload de um tutorial (em inglês) que resolve o seu problema!
São vários tutoriais: veja "Input Box"

link:

http://www.4shared.com/file/f36E7y1i/Chronics_Tutorials.html

No fim de cada tutorial você pode abrir o arquivo *.gmk de exemplo do tuto.

Espero ter ajudado.
avatar
leocesar

Data de inscrição : 24/09/2010
Reputação : 0
Número de Mensagens : 98
Prêmios : [Resolvido]Como fazer uma caixa de texto para um browser web Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Como fazer uma caixa de texto para um browser web Empty Re: [Resolvido]Como fazer uma caixa de texto para um browser web

Mensagem por afonso_silva Sex 15 Out 2010, 14:55

leocesar escreveu:Fiz um upload de um tutorial (em inglês) que resolve o seu problema!
São vários tutoriais: veja "Input Box"

link:

http://www.4shared.com/file/f36E7y1i/Chronics_Tutorials.html

No fim de cada tutorial você pode abrir o arquivo *.gmk de exemplo do tuto.

Espero ter ajudado.

Obrigadão.
Vou dar uma espreitadela depois faço um edit


Edit:

O arquivo de ajuda não funciona, quando o abro diz: "A navegação para a página web foi cancelada"

Você pode postar aqui o tuto? Surprised
afonso_silva
afonso_silva

Data de inscrição : 29/05/2010
Reputação : 0
Número de Mensagens : 147
Prêmios : [Resolvido]Como fazer uma caixa de texto para um browser web Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Como fazer uma caixa de texto para um browser web Empty Re: [Resolvido]Como fazer uma caixa de texto para um browser web

Mensagem por leocesar Sex 15 Out 2010, 15:19

Pega aí! Está em PDF e com os arquivos fonte, bons estudos!

Caixa de texto no Game Maker.rar


Você está usando o Windows 7? Eu não me lembro como resolvi isso, mas acho que você deve desabilitar o controle de contas de usuário ou dar permissões de administrador para abrir arquivos *.chm (arquivos de help).

Mesmo assim aí vai o tuto (sem imagens):

--------------------------------------------------------------------------------

Input Box
A tutorial by Andrew Barber aka Chronic
An input box is something that can be very important in some games, and could be used in a lot of situations. In this tutorial i will explain how to create such a thing, aswell as how to get information from it.

We will first start off with how to make Game Maker draw text you type to the screen.

Open Game Maker if you havn't done so already and to it add a new room and 2 objects. Rename object0 to obj_inputParent, and object1 to obj_inputBox. Add an instance of obj_inputBox to the room. You can now close the room as we do not need it at this point.

As the name suggests obj_inputParent will be a parent object, this is where all of our coding will go for the input box. obj_inputBox will be the child object. Go ahead and set obj_inputBox to have obj_inputParent as its parent object.


obj_inputBox
Add a Draw event to the obj_inputParent with the following script:

[DRAW]
{
draw_text(x,y,keyboard_string);
}

If you test the game at this point, you will see that as you type text will appear on the screen. However, pressing enter will not create a new line, in Game Maker new lines are created with a # character which can cause problems when you don't want this to happen.

Because # creates a new line, this means that should you ever want to draw the # character, then you need to place a backslash infont of it like so, \#.

In most cases using a newline in an input box is not the desired effect, so we need to stop this from happening by replacing # with \# when ever we need to draw the inputted text to screen, or use it in a dialog such as show_message().

To fix it we need to alter the script a little:

[DRAW]
{
showText = string_replace_all(keyboard_string,"#","\#");
draw_text(x,y,showText);
}

If you test it again, you will now see that typing a # will not create a new line, and instead be drawn as expected. The showText variable however will show the backslashes if you check this in debug mode.

We now need to make it so typing in the input box will only work if its active. For this we need to have a bounding box, which will require a sprite. So, add a sprite and rename it to spr_inputBack. So we can click anywhere on the sprite we need to disable "Precise collision checking" and for the Bounding Box option select "Full Image". This sprite now needs to be assign to obj_inputBox as its the instance we have in the room.


spr_inputBack
For my input box background i used the following sprite:


spr_inputBack - first frame
Add a Create event to obj_inputBox, here we will set up variables needed for the input box. At this point we only need to add the following:

[CREATE]
{
inputActive = false;
}

Because we have code in the drawing event, the sprite will not show up, so we need to draw this manually. Alter the drawing event script to the following:

[DRAW]
{
draw_sprite(sprite_index,inputActive,x,y);

showText = string_replace_all(keyboard_string,"#","\#");
draw_text(x,y,showText);
}

Note that for the image_index argument of draw_sprite() we have used inputActive. If another frame is added to spr_inputBack, then this will make it so the sprite changes when its active. For the second frame of the sprite, i copied the first and recolored the black to red.


spr_inputBack - second frame
Now add a Global Left Button event to obj_inputParent, This will be used to select and deselect the input box.

First of all we will need to check if when clicking, you're clicking on an object. We also need for it to return the instance ID of the object clicked if any. The function instance_position() is perfect for this because it also allows us to set the object type we want to look for, in this case obj_inputParent.

The following script will take store the instance ID of the object in the variable activeInstance, but only if the object is obj_inputParent, or a child of it. In every other case it will return -4, which is a keyword value for "noone". By knowing this we now have a way of selecting and deselecting the input box.

[Glob Left Button]
{
activeInstance = instance_position(mouse_x,mouse_y,obj_inputParent);

As it is this will only store the instance ID or -4, but do nothing with it. So we now need to add more to the script so we're able to something with the returned value from a click.


Logically, when a click is made we should make sure that all other instances of obj_inputParent should have inputActive set to false. We can do that by adding the following to the Global Left Click event:

[Glob Left Button]
with (obj_inputParent) { inputActive = false; }

Now we need to make it so that when clicking obj_inputParent its made active. First we need to check if activeInstance does not equal noone (-4), this must mean that an instance of obj_inputParent has been clicked on. Then with the instance ID we've stored in activeInstance, set inputActive for it to true. We also need to add in something to deal with pressing backspace to delete a character. This can be done by setting keyboard_string to the current value of inputText for that instance.

[Glob Left Button]
if (activeInstance != noone) {
with (activeInstance) {
keyboard_string = inputText;
inputActive = true;
}
}
}

Here is a complete version of the script.

[GLOB LEFT BUTTON]
{
activeInstance = instance_position(mouse_x,mouse_y,obj_inputParent);

with (obj_inputParent) { inputActive = false; }

if (activeInstance != noone) {
with (activeInstance) {
keyboard_string = inputText;
inputActive = true;
}
}
}

Because we are setting the keyboard_string to inputText, we need to set a default value to it otherwise when clicking the object to select it, an error will occur. The inputText variable will also allow us to set an initial value for what will appear in it. Alter the Create event to the following:

[CREATE]
{
inputActive = false;
inputText = "";
}

Now that we've set up the selecting and deselecting of the input box, you may have noticed that anything you type will still show up regardless of the selected state the object is in. To solve this we need to add one more event to obj_inputParent, along with some other minor changes.

Add an Any Key event to obj_inputParent with the script below. This will make sure we can only type in it when its active, aswell as store it in a local variable so we can retrive the data in it at a later point.

[ANY KEY]
{
if (inputActive = true) {
inputText = keyboard_string;
}
}

And alter the Drawing event to the this:

[DRAW]
{
draw_sprite(sprite_index,inputActive,x,y);

showText = string_replace_all(inputText,"#","\#");
draw_text(x,y,showText);
}

At this point the text box is completed and ready to use. Now each time you want to add another input box, you could add another instance of obj_inputBox or add another object and set it to be a parent of obj_inputPaent making it an instance input box. You don't need to add another object, however you will find it much easier being able to get information from a box by the objects name, instead of having to keep track of the instance IDs. Read below on how to read back the data inputted to a input box.


Retrieving Data

Getting the input data back from an input box is really simple. Because we store the text in a variable, all we need to know is the object name or ID. As i said above, using the name is much easier.

[N/A]
value = obj_inputBox.inputText;

Keep in mind this will return # as \#. So for example if you entered "1#2#3", inputText's value would be "1\#2\#3\#". To correct this we'll need to use the same method we used in the Drawing event.

[N/A]
value = string_replace_all(obj_inputBox.inputText,"#","\#");


Taking it an extra step

There are a number of other things you can do with this, for example making it so when you press the enter key, the input box will deselect. This can be done by adding the following line to the Any Key event within the IF statement.

[ANY KEY]
if keyboard_check(vk_enter) { inputActive = false; }

Next we could add a cursor to the input boxes that will show only when its selected. For this add these to lines to the Create event.

[CREATE]
inputCursor[0] = "";
inputCursor[1] = "_";

And alter the appropriate line in the Drawing event to:

[DRAW]
draw_text(x,y,showText + inputCursor[inputActive]);

The last thing we could do it add a character limit to things, Add the following to the Create event

[CREATE]
inputLimit = 0;

And this to the Any Key event within the IF statement. NOTE: Make sure you place this above "inputText = keyboard_string;"

[ANY KEY]
if (inputLimit > 0) && (string_length(keyboard_string) > inputLimit) {
keyboard_string = string_copy(keyboard_string,1,inputLimit);
}

The inputLimit variable in the Create event can now be used to set a limit to the amount of characters you wish to allow inputted. If the inputLimit variable is 0 or a negative number, there will be no limit.

To use limits on a per object basis you will need to add a Create event to the object with the following:

[CREATE]
{
event_inherited();
inputLimit = 10;
}

This will inherit the create event from obj_inputParent, and then set the limit to 10.

And thats all there is... Thanks for reading, and i hope you've learnt something from this.

avatar
leocesar

Data de inscrição : 24/09/2010
Reputação : 0
Número de Mensagens : 98
Prêmios : [Resolvido]Como fazer uma caixa de texto para um browser web Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Como fazer uma caixa de texto para um browser web Empty Re: [Resolvido]Como fazer uma caixa de texto para um browser web

Mensagem por afonso_silva Sex 15 Out 2010, 15:24

Pega aí! Está em PDF e com os arquivos fonte, bons estudos!

Caixa de texto no Game Maker.rar


Você está usando o Windows 7? Eu não me lembro como resolvi isso, mas acho que você deve desabilitar o controle de contas de usuário ou dar permissões de administrador para abrir arquivos *.chm (arquivos de help).

Mesmo assim aí vai o tuto (sem imagens):

Muito obrigado, isso vai ajudar-me bastante


OFF Topic: Vi os seus projectos no seu canal do Youtube e só posso dizer que são excelentes. E também acho que o seu curso à distância vai ser um sucesso

EDIT:

Não sei será pedir muito, mas vejo que não é possível utilizar utilizar a área de transferência nesta engine, nem selecionar texto. Dá para fazer alguma coisa para mudar isto?

Outro EDIT:
Testei a sua caixa de texto, só que problema persiste: o texto é escrito na caixa do google e não na barra de endereço. Se alguém puder ajudar agradeço
afonso_silva
afonso_silva

Data de inscrição : 29/05/2010
Reputação : 0
Número de Mensagens : 147
Prêmios : [Resolvido]Como fazer uma caixa de texto para um browser web Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Como fazer uma caixa de texto para um browser web Empty Re: [Resolvido]Como fazer uma caixa de texto para um browser web

Mensagem por leocesar Sex 15 Out 2010, 21:54

Valeu pela força grande Afonso!
Se puder me passar o seu arquivo do projeto, eu posso dar uma olhada e alterar para sua necessidade.
avatar
leocesar

Data de inscrição : 24/09/2010
Reputação : 0
Número de Mensagens : 98
Prêmios : [Resolvido]Como fazer uma caixa de texto para um browser web Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Como fazer uma caixa de texto para um browser web Empty Re: [Resolvido]Como fazer uma caixa de texto para um browser web

Mensagem por afonso_silva Sáb 16 Out 2010, 06:34

Tá bem, vou hospedar o projecto

Aqui está o link:

http://www.mediafire.com/?ytmslcqmcb2m0b5

Como pode ver, a caixa de texto funciona lindamente se eu retirar o objecto "controlador"
afonso_silva
afonso_silva

Data de inscrição : 29/05/2010
Reputação : 0
Número de Mensagens : 147
Prêmios : [Resolvido]Como fazer uma caixa de texto para um browser web Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Como fazer uma caixa de texto para um browser web Empty Re: [Resolvido]Como fazer uma caixa de texto para um browser web

Mensagem por leocesar Dom 17 Out 2010, 02:41

Verifiquei o seu projeto Afonso e cheguei as seguintes conclusões:

O problema não está no seu código e sim na DLL TinyWeb.

Essa DLL coloca o foco do teclado para o componente ActiveX (Browser Internet Explorer). Dessa forma o objeto “URL Bar” não reconhece o que você está digitando!

Uma alternativa é usar a função: get_string() para escrever o endereço desejado e ir para essa página.

Obs. Verifiquei alternativas de DLLs e não encontrei nenhuma que atenda ao seu propósito (ter uma barra de endereço modificada feita no Game Maker.

Talvez outra saída seja usar a função: splash_show_web() (Game Maker 8 Pro) ela abre o navegador na janela da aplicação e pode ser fechada.

Espero ter ajudado.
avatar
leocesar

Data de inscrição : 24/09/2010
Reputação : 0
Número de Mensagens : 98
Prêmios : [Resolvido]Como fazer uma caixa de texto para um browser web Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Como fazer uma caixa de texto para um browser web Empty Re: [Resolvido]Como fazer uma caixa de texto para um browser web

Mensagem por afonso_silva Dom 17 Out 2010, 14:32

leocesar escreveu:Verifiquei o seu projeto Afonso e cheguei as seguintes conclusões:

O problema não está no seu código e sim na DLL TinyWeb.

Essa DLL coloca o foco do teclado para o componente ActiveX (Browser Internet Explorer). Dessa forma o objeto “URL Bar” não reconhece o que você está digitando!

Uma alternativa é usar a função: get_string() para escrever o endereço desejado e ir para essa página.

Obs. Verifiquei alternativas de DLLs e não encontrei nenhuma que atenda ao seu propósito (ter uma barra de endereço modificada feita no Game Maker.

Talvez outra saída seja usar a função: splash_show_web() (Game Maker 8 Pro) ela abre o navegador na janela da aplicação e pode ser fechada.

Espero ter ajudado.

Obrigado leocesar. Acho que vou passar a utilizar a DLL dtbrowser, pois apresenta muitas funcionalidades, entre as quais a barra de endereços.

Vou por lá em cima resolvido
afonso_silva
afonso_silva

Data de inscrição : 29/05/2010
Reputação : 0
Número de Mensagens : 147
Prêmios : [Resolvido]Como fazer uma caixa de texto para um browser web Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Como fazer uma caixa de texto para um browser web Empty Re: [Resolvido]Como fazer uma caixa de texto para um browser web

Mensagem por leocesar Dom 17 Out 2010, 16:45

Sucesso na sua aplicação!
avatar
leocesar

Data de inscrição : 24/09/2010
Reputação : 0
Número de Mensagens : 98
Prêmios : [Resolvido]Como fazer uma caixa de texto para um browser web Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Como fazer uma caixa de texto para um browser web Empty Re: [Resolvido]Como fazer uma caixa de texto para um browser web

Mensagem por Conteúdo patrocinado


Conteúdo patrocinado


Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

 
Permissões neste sub-fórum
Não podes responder a tópicos