Giter VIP home page Giter VIP logo

pygame-textinput's Introduction

Pygame TextBox Input Module

Features

  • This Class lets you write text at the blinking cursor.
  • Wraps text to the next line if it exceeds the max_width.
  • Enter, Delete, Home, End, Page Up and Page Down key works.
  • Cursor can be moved using arrow keys or click on character to jump directly.
  • Scrolling using mouse or scroll bar.
  • Text Selection using mouse.
  • Cut, Copy, Paste and Select all using shortcut.
  • Ctrl and Shift shortcut works.
  • It works just like you expect.

Using the Module

Its very simple to use this module. Create an object of the Class and then feed the update() with pygame-events.

  • It will create surfaces of each line and store it in list only when any changes are made in the input_string for efficient rendering. List can be get using get_surface().
  • Then call the render().
  • If you don't want the text object to be updated with events.
    • Pass False to update().
    • It will not take any input and it will not render cursor too indicating its inactive.

Some part of code is borrowed from Pygame Text Input under the MIT license.

pygame-textinput's People

Contributors

yashjogani avatar

Stargazers

 avatar

Watchers

 avatar

pygame-textinput's Issues

Adding Ctrl+V / Ctrl+C functionality

I was wondering if you could add control copy + paste functionality into this class? I have some base code that would work to a degree, however I am not experienced enough to add it to your class. I've left the example of how to do so below.
pygame.scrap.init()
pygame.scrap.set_mode(pygame.SCRAP_CLIPBOARD)
#event loop
events = pygame.event.get()

    for event in events:
        if (event.type == pygame.QUIT):
            pygame.quit()
        if (event.type == pygame.KEYDOWN):
            # checking for ctrl + V
            if event.key == pygame.K_v and event.mod & pygame.KMOD_CTRL:
                 # adding text to a text box called promptBox, where .text is the thing that holds the text
                pasted_text =  pygame.scrap.get("text/plain;charset=utf-8").decode()
                promptBox.text = promptBox.text[:-1]
                promptBox.text += pasted_text

I did this using a different inputBox class, which is why i did .text, however I don't know how I could apply this functionality to your class, so I was wondering if you had any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.